"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: mark got_privsep_exec_child as __dead
To:
gameoftrees@openbsd.org
Date:
Fri, 17 Dec 2021 23:13:34 +0100

Download raw body.

Thread
Omar Polo:

> P.S.: is the cast to char * for NULL really needed?
>  
> -	if (execl(path, path, repo_path, (char *)NULL) == -1) {

Yes, it's the safe thing to do for portability.  You can't rely on
NULL being a pointer type.  It could just be int 0.

And since execl() takes a variable number of arguments, the compiler
doesn't know to cast int 0 (32 bits) to a pointer (possibly 64 bits).
If arguments are passed in registers, it's probably still safe in
practice, but once they're spilled on the stack, size may matter.

OpenBSD went from defining NULL as 0, to 0L in 2002, to (void *)0
in 2011, to the current state of <sys/_null> in 2016.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de