Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Mar 2002 04:44:42 -0600
From:      "Mike Meyer" <mwm-dated-1015843484.1eabc5@mired.org>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        "Mike Meyer" <mwm-dated-1015842633.bc6005@mired.org>, obrien@FreeBSD.ORG, Mike Meyer <mwm-dated-1015831171.a21ab0@mired.org>, Giorgos Keramidas <keramida@FreeBSD.ORG>, hackers@FreeBSD.ORG
Subject:   Re: RFC: style(9) isn't explicit about booleans for testing. 
Message-ID:  <15493.62234.943657.776598@guru.mired.org>
In-Reply-To: <30203.1015411062@critter.freebsd.dk>
References:  <15493.61384.557931.883967@guru.mired.org> <30203.1015411062@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
Poul-Henning Kamp <phk@critter.freebsd.dk> types:
> Ahh, but here you hit one of my pet-peeves.  I hate assignments inside
> conditionals.  I prefer the above written as:
> Anyway, if you want it spelled out the way I would want it:
> 
> 0. No assignments in if()
> 
> 1. In conditions, pointers should be explicitly compared against NULL:
> 
> 	if (foo == NULL)
> or
> 	if (foo != NULL)
> 
> 2. In conditions, non-interger numeric types should be explicitly compared
>    to zero
> 
> 	if (float_t == 0.0)
> 
> 3. Integers need not be explicitly compared to zero:
> 
> 	if (foo & MASK)
> not
> 	if ((foo & MASK) != 0)

I would like it spelled out. Since style(9) uses assignments in
conditionals in it's examples, rule 0 probably won't fly. Rule 1 and 2
are redundant.

Looking at the text in the page on -stable, I think the one-word
change from boolean to "integer" would remove the ambiguity.

	Thank you,
	<mike
 --
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

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?15493.62234.943657.776598>