On 07/14/2010 04:04 AM, Ævar Arnfjörð Bjarmason wrote: > On Wed, Jul 14, 2010 at 03:01, Greg Brockman <gdb@xxxxxxx> wrote: >> + execl(prog, prog, (char *) NULL); > > Why the casting of NULL? It's not done in the builtin/help.c code. > > Anyway, if it was cast it should be to (const char *), shouldn't it? When a NULL sentinel is passed to a varargs function that only understands 'char *' arguments, the NULL must be cast specifically, otherwise it will appear in the varargs array as an int or a long. execl() is an example of a varargs function that only uses varargs functionality to accept a variable *number* of arguments, it does not allow for arguments of differing types, so it does not check the types of its arguments at all. On any platform where an int and a pointer are not the same size, this can cause a serious problem. When we came across this problem in Asterisk, we added a macro called SENTINEL (that just expands to the proper type for the target platform) that is used in these cases, so that it is clear to the reader of the code what is going on. -- Kevin P. Fleming Digium, Inc. | Director of Software Technologies 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA skype: kpfleming | jabber: kfleming@xxxxxxxxxx Check us out at www.digium.com & www.asterisk.org -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html