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

Re: [PATCH/RFC 4/4] Add interactive mode to git-shell for user-friendliness

From
KFKevin P. Fleming <kpfleming@digium.com>
Date
Jul 14, 2010, 13:59 UTC
Message-ID
<4C3DC2BD.6020907@digium.com>
In-Reply-To
<AANLkTil4XkVXM-96Jb7UOpH2CZBmtXEf7eEIIgrsqhg5@mail.gmail.com>
On 07/14/2010 04:04 AM, Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> On Wed, Jul 14, 2010 at 03:01, Greg Brockman <gdb@mit.edu> 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@digium.com
Check us out at www.digium.com & www.asterisk.org
Previous: Ævar Arnfjörð BjarmasonNext: Bernhard R. Link
Message 9 of 19 in “Providing mechanism to list available repositories”
  1. 0/4 Providing mechanism to list available repositoriesGreg Brockman, Jul 14, 2010
  2. 1/4 Allow creation of arbitrary git-shell commandsGreg Brockman, Jul 14, 2010
  3. Junio C HamanoJul 14, 2010
  4. Greg BrockmanJul 14, 2010
  5. 2/4 git-shell-commands: Add a command to list bare reposGreg Brockman, Jul 14, 2010
  6. 3/4 git-shell-commands: Add a help commandGreg Brockman, Jul 14, 2010
  7. 4/4 Add interactive mode to git-shell for user-friendlinessGreg Brockman, Jul 14, 2010
  8. Ævar Arnfjörð BjarmasonJul 14, 2010
  9. Kevin P. FlemingJul 14, 2010
  10. Bernhard R. LinkJul 14, 2010
  11. Thomas RastJul 14, 2010
  12. Cast execl*() NULL sentinels to (char *)Thomas Rast, Jul 24, 2010
  13. Ævar Arnfjörð BjarmasonJul 24, 2010
  14. Johannes SixtJul 14, 2010
  15. Junio C HamanoJul 14, 2010
  16. Greg BrockmanJul 14, 2010
  17. Greg BrockmanJul 17, 2010
  18. Jonathan NiederJul 17, 2010
  19. Greg BrockmanJul 17, 2010

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.