Date: Thu, 7 Mar 2002 15:27:49 -0500 From: Garance A Drosihn <drosih@rpi.edu> To: "Brian T.Schellenberger" <bts@babbleon.org> Cc: hackers@FreeBSD.ORG Subject: Re: RFC: style(9) isn't explicit about booleans for testing -- an actual analysis of the code! Message-ID: <p05101508b8ad7b67c653@[128.113.24.47]> In-Reply-To: <20020307071630.E26DBBA03@i8k.babbleon.org> References: <52204.1015480748@critter.freebsd.dk> <20020307071630.E26DBBA03@i8k.babbleon.org>
next in thread | previous in thread | raw e-mail | index | archive | help
At 2:16 AM -0500 3/7/02, Brian T.Schellenberger wrote: >Maybe your brain has gotten used to it, but to us ordinary >mortals, even us ordinary mortals who've been slogging C >code for time periods that can be measured in decades >(yikes!), it is very tempting to read > > if (!strcmp(a,b,l)) > >as "if the strings don't compare" which, in ordinary usage, >means don't compare *equal*. But of course the C program >is going to proceed to do exactly the opposite of that. Okay, I will agree I have made that mistake a few times. Not often, but it really burns me up when I realize that's the source of some bug. So, that sounds like a good reason. >But *ALL* of this is beside the nominal point ANYWAY, which >is to discuss the proper wording for the man(9) style guide >which is supposed to document how things things are actually >done in the kernel, not personal preference. As to the wording, PHK suggested that the wording for this rule in style(9) be changed: - - - get rid of the word boolean, ie: change Do not use ! for tests unless it is a boolean, e.g. use to Do not use ! for tests unless it is an integer type, e.g. use - - - Dave O'Brien claimed the very same rule was *only* there to prevent "if (!strcmp(a,b))". May I suggest that we probably want two different rules? Change the current rule so it says 'integer type' instead of 'boolean' (which doesn't really exist in C anyway), and then add the rule about strcmp()? -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05101508b8ad7b67c653>