Date: Tue, 10 Sep 2002 19:09:26 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: jmallett@FreeBSD.org Cc: fanf@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.bin/uudecode uudecode.c Message-ID: <20020910.190926.94553760.imp@bsdimp.com> In-Reply-To: <20020910145812.B78992@FreeBSD.org> References: <200209102053.g8AKrkvc055026@freefall.freebsd.org> <20020910145812.B78992@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20020910145812.B78992@FreeBSD.org>
Juli Mallett <jmallett@FreeBSD.org> writes:
: * De: Tony Finch <fanf@FreeBSD.org> [ Data: 2002-09-10 ]
: [ Subjecte: cvs commit: src/usr.bin/uudecode uudecode.c ]
: > fanf 2002/09/10 13:53:46 PDT
: >
: > Modified files:
: > usr.bin/uudecode uudecode.c
: > Log:
: > Style: Don't treat pointers as booleans.
:
: Do we have a firm style(9) ruling on that? There's like two cases I know
: of where it's justified, both are code that return pointers, and use 0 / false
: internally. I loathe if(ptr) almost as much as if(foo &bitmask) and if(!strcmp)
That's lots of places in the kernel that use 'if (ptr)' or 'if (!ptr)'
but a lot of that code is new. Style(9) does say, however:
Test pointers against NULL, e.g., use:
(p = f()) == NULL
not:
!(p = f())
So the documented, preferred style is to use if (p != NULL) rather
than if (p).
Warner
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020910.190926.94553760.imp>
