On 2002-03-05 12:59, Julian Elischer wrote:
> 
> On Tue, 5 Mar 2002, Giorgos Keramidas wrote:
> > > 
> > > Read the man page to try and decide if you should write "if (x)" or
> > > if (x != 0).
> > > 
> > > >Fix:
> > > 
> > > Apply the attached page to the style(9) man page.
> [...]
> 
> the one that I stop to think about is:
> 
> if (!(flags & FLAGSET))
> 
> or should that be 
> 
> if ((flags & FLAGSET) == 0)
> 
> it depends on what you define as a Boolean.
>
> If FLAGSET has > 1 bit in it then it it still possibly a boolean?

I was reading parts of the sys/netinet tree lately.  Most of the
places I have seen so far use the second style, even for flags that
are stored in bitfields.  Quoting ip_input.c:

        if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) == 0) {
                ipstat.ips_badaddr++;
                goto bad;
        }

This is what I prefer too, but my own personal preference is probably
based on what I've seen so far, which is (I have to admit) very limited.


Giorgos Keramidas                       FreeBSD Documentation Project
keramida@{freebsd.org,ceid.upatras.gr}  http://www.FreeBSD.org/docproj/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to