httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Robinson <d...@esi.co.uk>
Subject Re: I *don't* want Paul's style guide.
Date Tue, 02 Jul 1996 08:40:40 GMT
On Mon, 1 Jul 1996, Robert S. Thau wrote:
> 	/*
>          *  Also, test pointers
> 	 * against NULL, i.e. use:
> 	 *
> 	 * 	(p = f()) == NULL
> 	 * not:
> 	 *	!(p = f())
>          */
> !foo is used all over the current Apache code.

This is one that really irritates me (perhaps almost as much as my
comment style irritates rst 8-( ) because to my mind, '!' takes a boolean
argument, not a pointer. (Reasons below.)

But, amazingly, I _can_ actually understand what is meant here.
Am I the only person who thinks that this discussion has turned into a
complete waste of time?

 David.

Why (!p) is wrong
-----------------

As I understand C,
char *p;

 if (!p) ...

is equivalent to
 if (!(int)p) ...

Which seems to me to mean something quite different to
 if (p != NULL) ...

In particular what happens when sizeof(char *) > sizeof(int)
e.g. Cray or Digital UNIX, or when NULL != (void *)0 (maybe on some
microsoft systems) ?

Even if in practice the two test are likely to evaulate to the same
answer, it does seem like sloppy programming to me.



Mime
View raw message