git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Use explicit pointers for execl...() sentinels.

From
THTimo Hirvonen <tihirvon@gmail.com>
Date
Mar 12, 2006, 18:08 UTC
Message-ID
<20060312200812.3fb04638.tihirvon@gmail.com>
In-Reply-To
<slrne18mq3.fr9.mdw@metalzone.distorted.org.uk>

On Sun, 12 Mar 2006 17:32:51 +0000 (UTC) Mark Wooding <mdw@distorted.org.uk> wrote:

Show 5 quoted lines
> Besides, (void *)0 fixes /this particular/ problem, because `void *' and
> `char *' have the same representation (6.2.5#27).  This wouldn't help us
> with a putative function which takes an arbitrary number of `foo *'
> pointers, since nothing guarantees that `void *' and `foo *' have
> similar representations.  You'd have to say `(foo *)0' or `(foo *)NULL'.

NULL pointer does not point to any data, it just says it's 'empty'. So it doesn't need to be same type pointer as specified in the function prototype. Pointers are just addresses, it doesn't matter from to code generation point of view whether it is (char *)0 or (void *)0.

> Don't know: didn't look.  0L won't do the right thing with IL32LLP64, if
> anyone was actually crazy enough to specify such an ABI.  The point is,
> there's not much 
sizeof(unsigned long) is sizeof(void *) in real world.
> > How about fixing those systems instead of making the git source code
> > unreadable.
> 
> Because, according to the C and POSIX specs, they're not wrong.
They didn't think of 64-bit architectures back then, I suppose.
> The right fix from the point of view of a C implementation would be to
> define NULL to be some weird __null_pointer token which the compiler
> could warn about whenever it was used in an untyped argument context.
In practice (void *)0 is good enough.
> (Besides, I don't find bare or casted `0' unreadable.  Maybe I'm just
> strange.)
'ugly' would have been better word than 'unreadable'.
-- 
http://onion.dynserv.net/~timo/
Previous: Mark WoodingNext: Jeff King
Message 7 of 20 in “Trivial warning fix for imap-send.c”
  1. Trivial warning fix for imap-send.cArt Haas, Mar 11, 2006
  2. Mark WoodingMar 12, 2006
  3. Junio C HamanoMar 12, 2006
  4. Use explicit pointers for execl...() sentinels.Mark Wooding, Mar 12, 2006
  5. Timo HirvonenMar 12, 2006
  6. Mark WoodingMar 12, 2006
  7. Timo HirvonenMar 12, 2006
  8. Jeff KingMar 13, 2006
  9. Linus TorvaldsMar 12, 2006
  10. Mark WoodingMar 12, 2006
  11. A Large Angry SCMMar 12, 2006
  12. H. Peter AnvinMar 13, 2006
  13. A Large Angry SCMMar 13, 2006
  14. Linus TorvaldsMar 13, 2006
  15. H. Peter AnvinMar 13, 2006
  16. Linus TorvaldsMar 13, 2006
  17. Olivier GalibertMar 13, 2006
  18. Jeff KingMar 13, 2006
  19. H. Peter AnvinMar 13, 2006
  20. Linus TorvaldsMar 12, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.