[ccan] [PATCH 4/5] altstack: Don't use 0 pointer literals

Rusty Russell rusty at rustcorp.com.au
Tue Jun 14 14:15:10 AEST 2016


Dan Good <dan at dancancode.com> writes:
> Hi David,
>
> I'm back home in front of a real keyboard, and want to follow up with you
> about your patches.  I must admit that my usual practice is to use NULL,
> and not 0.  Around the time I wrote altstack I had recently read Jen
> Gustedt's book, Modern C.  In it, he makes the point that NULL hides more
> than it clarifies (see section 11.7).

(I don't really care: your code, your style).  But...

He is so horrifically wrong, it's amazing.

Section 7.17 is loosened from ANSI C which said NULL was 0, presumably
to *allow* compilers to avoid the varargs issue.  A compiler *could* do
insane shit to make that problem even worse, but you would never use
such a compiler.  There are other legal-but-insane things a compiler can
do, too, and the answer is the same; real code won't work, nobody else
cares.

OTOH, using 0 in place of NULL makes for much more potential type order
confusion.  Not to mention confusing every damn C programmer on the
planet.

Note, I also assume NULL is all zero-bits, that size_t can hold a
ptrdiff_t, and that a pointer to a function which takes a type *
argument can be cast and called as a function which takes a void *.

If someone ports CCAN to a platform where those are not true, I'd be
fascinated...

Cheers,
Rusty.


More information about the ccan mailing list