All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Dan Good <dan@dancancode.com>,
	David Gibson <david@gibson.dropbear.id.au>
Cc: ccan <ccan@lists.ozlabs.org>
Subject: Re: [PATCH 4/5] altstack: Don't use 0 pointer literals
Date: Tue, 14 Jun 2016 13:45:10 +0930	[thread overview]
Message-ID: <87eg8076ep.fsf@rustcorp.com.au> (raw)
In-Reply-To: <CACNkOJNPh_AUB5+0GhJ1W5GQSqN1efRpxPFajUKOPXdsVe4nng@mail.gmail.com>

Dan Good <dan@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.
_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

  reply	other threads:[~2016-06-14  4:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03  8:41 [PATCH 0/5] altstack: cleanups David Gibson
2016-06-03  8:41 ` [PATCH 1/5] altstack: Consolidate thread-local variables David Gibson
2016-06-03  8:42 ` [PATCH 2/5] altstack: Restore alternate signal stack state David Gibson
2016-06-03  8:42 ` [PATCH 3/5] altstack: Use ptrint instead of bare casts David Gibson
2016-06-03  8:42 ` [PATCH 4/5] altstack: Don't use 0 pointer literals David Gibson
2016-06-12  1:27   ` Dan Good
2016-06-14  4:15     ` Rusty Russell [this message]
2016-06-16  6:45       ` David Gibson
2016-06-16 20:38         ` Dan Good
2016-06-03  8:42 ` [PATCH 5/5] altstack: Don't log internal calls in test cases David Gibson
2016-06-12  2:10   ` Dan Good
2016-06-16  7:34     ` David Gibson
2016-06-16 20:45       ` Dan Good
2016-06-20  8:26         ` David Gibson
2016-06-03 23:29 ` [PATCH 0/5] altstack: cleanups Dan Good

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eg8076ep.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=ccan@lists.ozlabs.org \
    --cc=dan@dancancode.com \
    --cc=david@gibson.dropbear.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.