All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: ccan <ccan@lists.ozlabs.org>
Subject: Re: [PATCH 4/5] altstack: Don't use 0 pointer literals
Date: Thu, 16 Jun 2016 16:45:43 +1000	[thread overview]
Message-ID: <20160616064543.GE1642@voom.fritz.box> (raw)
In-Reply-To: <87eg8076ep.fsf@rustcorp.com.au>


[-- Attachment #1.1: Type: text/plain, Size: 2170 bytes --]

On Tue, Jun 14, 2016 at 01:45:10PM +0930, Paul 'Rusty' Russell wrote:
> 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.

Yeah.  I can kind of see the hint of a good idea in those articles,
but on balance they're really not convincing.  Basically, as Rusty
says, matching the conventions of the huge bulk of existing C code
outweighs the value of working with a compiler/library that has gone
out of its way to implement this stupidly.

> Note, I also assume NULL is all zero-bits,

I try to avoid that one, although I can't be sure I always have - I'm
not sure, but I think one of the s390 variants might break this.

> that size_t can hold a
> ptrdiff_t,

Dunno if I've assumed that much.

> and that a pointer to a function which takes a type *
> argument can be cast and called as a function which takes a void *.

Yeah, I've used that.

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

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

  reply	other threads:[~2016-06-16 11:12 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
2016-06-16  6:45       ` David Gibson [this message]
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=20160616064543.GE1642@voom.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=ccan@lists.ozlabs.org \
    --cc=rusty@rustcorp.com.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.