This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/3] posix: New Linux posix_spawn{p} implementation


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]