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

Rusty Russell <[email protected]> Tue, 14 Jun 2016 13:45:10 +0930
Newsgroups org.ozlabs.lists.ccan
Message-ID <[email protected]>
Dan Good <[email protected]> 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.
_______________________________________________
ccan mailing list
[email protected]
https://lists.ozlabs.org/listinfo/ccan