Re: Critical crypto bug leaves Linux, hundreds of apps open ...
by userbinator on Tuesday March 04, 2014 @07:14PM
(#7344259)
Using nonzero for errors means you can do the same thing. This is common in things like this:
Additionally, if the return is a fail/pass status, there is only one success (0), and you can use all the nonzero values for error codes.
[ Parent
| on HN ]
Re: Critical crypto bug leaves Linux, hundreds of apps open ...
by prewett on Wednesday March 05, 2014 @07:54AM
(#7346639)
Yes, you can, but that doesn't read very well to my eyes, given most function names. if(open()), if(read()), if (CreateWindowExW()), all suggest success to me.
if (!open(...)) goto fail;
if (!read(...)) goto fail;
if (!close(...)) goto fail;
reads a lot nicer to me. Although, the reality is that you need to assign to an error variable, which makes it not as nice and clean.