Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Mar 2002 15:58:50 -0800
From:      "David O'Brien" <obrien@freebsd.org>
To:        Giorgos Keramidas <keramida@freebsd.org>
Cc:        hackers@freebsd.org
Subject:   Re: RFC: style(9) isn't explicit about booleans for testing.
Message-ID:  <20020305155850.A38095@dragon.nuxi.com>
In-Reply-To: <20020305201350.GC4820@hades.hell.gr>; from keramida@freebsd.org on Tue, Mar 05, 2002 at 10:13:50PM %2B0200
References:  <20020305201350.GC4820@hades.hell.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Mar 05, 2002 at 10:13:50PM +0200, Giorgos Keramidas wrote:
> > -Don't use '!' for tests unless it's a boolean, e.g. use
> > +For tests, always compare the value to the appropriate 0 instead of
> > +checking it directly, unless the value is a boolean.
> > +For pointers, use:
> > +.Bd -literal
> > +if (p != NULL)
> > +.Ed
> > +.Pp
> > +not
> > +.PP
> > +.Bd -literal
> > +if (!p)
> > +.Ed
> > +.Pp
> > +For other values, use:
> >  .Bd -literal
> >  if (*p == '\e0')
> >  .Ed
> >  .Pp
> >  not
> >  .Bd -literal
> > -if (!*p)
> > +if (*p)
> > +.Ed
> > +.Pp
> > +unless the value is a boolean. In that case, use:
> > +.Bd -literal
> > +if (p)
> > +.Ed
> > +.Pp
> > +and
> > +.Bd -literal
> > +if (!p)


Please show examples from /sys that back up this change.  To state this
explicitly, I think a significant number of /sys files should be
following it.

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?20020305155850.A38095>