DragonFly commits List (threaded) for 2004-12
Re: cvs commit: src/usr.bin/newgrp
Matthew Dillon wrote:
:liamfoy 2004/12/08 14:00:32 PST
:DragonFly src repository
: Modified files:
: usr.bin/newgrp newgrp.c
: - Check the return value of setenv(). We should check this value since
: setenv() uses both malloc and realloc.
: Revision Changes Path
: 1.2 +9 -3 src/usr.bin/newgrp/newgrp.c
That's fine, though the typical way of checking the return
value is to check for it < 0 rather then exactly equal to
-1. Both are correct, but < 0 is used the most often in the code
base and considered easier to read.
Is it? I always found == -1 to be rather straightforward, and
considering (according to SUSv3) that setenv _must_ return only 0 or -1,
I see no point to check for any other value. If setenv were to return
anything else on failure, and you would need to check what the error
was, I could understand this. But errno is set when setenv errors, and
returns -1, so I'm stumped as to why checking for < 0 is considered to
be easier to read, since it seems more like an obfuscation to what the
case actually can be in reality.
Devon H. O'Dell