Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 8 May 2013 07:58:46 +0400
From: Solar Designer <solar@...nwall.com>
To: john-dev@...ts.openwall.com
Subject: Re: Constification and format interface clarification

On Wed, May 08, 2013 at 01:40:00AM +0200, magnum wrote:
> On 8 May, 2013, at 0:46 , Alexander Cherepanov <cherepan@...me.ru> wrote:
> > 1. Constification. IMHO it would be good to add a "const" qualifier to function parameters when they are pointers pointing to data which is not modified. It will guarantee that string literals are not modified, make the code more robust, perhaps permit more optimizations etc.
> 
> http://www.openwall.com/lists/john-dev/2013/02/08/6

Thank you for locating this posting in the archive.

> I would be eager to do this if there was significant performance gains to win.

As the posting referenced above indicates, there's absolutely no
performance gain to expect from constifying the pointers.

There is potential performance gain from use of the restrict keyword,
but it may also make the code less robust (some of those uses of
restrict may be bugs, right away or at a later time).

> The "bug protection" alone might not be worth it.

I think the added clarity is worth it.  We could write a comment that
"this function does not alter the memory area referred to by its pointer
argument" or we could simply add const.

Alexander

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ