This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 3/3] posix: New Linux posix_spawn{p} implementation
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Paul Eggert <eggert at cs dot ucla dot edu>, libc-alpha at sourceware dot org
- Date: Mon, 29 Feb 2016 14:45:03 -0300
- Subject: Re: [PATCH 3/3] posix: New Linux posix_spawn{p} implementation
- Authentication-results: sourceware.org; auth=none
- References: <1456495001-5298-1-git-send-email-adhemerval dot zanella at linaro dot org> <1456495001-5298-4-git-send-email-adhemerval dot zanella at linaro dot org> <56D0B319 dot 3060005 at cs dot ucla dot edu> <56D0D129 dot 2070201 at linaro dot org> <56D26862 dot 9090702 at cs dot ucla dot edu>
On 28-02-2016 00:24, Paul Eggert wrote:
> Adhemerval Zanella wrote:
>> I see using const on complex expression might help compiler
>> get logic errors (where the variable is set to a different value)
>
> In that case, you should also put "register" in your local declarations too, right? Something like this:
>
> register const int prot = PROT_READ | PROT_WRITE;
>
> That way, you are also guarded against errors where later code mistakenly attempts to take the address of 'prot'.
>
> You may think I'm joking, but I have worked with programmers who believe in this sort of thing, and I have experience with (non-GNU) code using this style. The problem with this approach is that the attributes get in the way of reading the code. Attributes like 'const' can make sense for globals, but for local variables the hassle of maintaining them typically outweighs the meager benefits of having them. That's certainly the case for this example, anyway.
Fair enough, I will change that.