Skip to content

Commit 5d31475

Browse files
trastgitster
authored andcommitted
Cast execl*() NULL sentinels to (char *)
The NULL sentinel argument to the execl*() family of calls must be cast to (char *), as otherwise: - platforms where NULL is just 0 (not (void *)) would pass an int - (admittedly esoteric) platforms where NULL is (void *)0 and (void *) and (char *) have different memory layouts would pass the wrong kind of pointer Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cdad3c5 commit 5d31475

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

builtin/help.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void exec_woman_emacs(const char *path, const char *page)
120120
if (!path)
121121
path = "emacsclient";
122122
strbuf_addf(&man_page, "(woman \"%s\")", page);
123-
execlp(path, "emacsclient", "-e", man_page.buf, NULL);
123+
execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
124124
warning("failed to exec '%s': %s", path, strerror(errno));
125125
}
126126
}
@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)
148148
} else
149149
path = "kfmclient";
150150
strbuf_addf(&man_page, "man:%s(1)", page);
151-
execlp(path, filename, "newTab", man_page.buf, NULL);
151+
execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
152152
warning("failed to exec '%s': %s", path, strerror(errno));
153153
}
154154
}
@@ -157,15 +157,15 @@ static void exec_man_man(const char *path, const char *page)
157157
{
158158
if (!path)
159159
path = "man";
160-
execlp(path, "man", page, NULL);
160+
execlp(path, "man", page, (char *)NULL);
161161
warning("failed to exec '%s': %s", path, strerror(errno));
162162
}
163163

164164
static void exec_man_cmd(const char *cmd, const char *page)
165165
{
166166
struct strbuf shell_cmd = STRBUF_INIT;
167167
strbuf_addf(&shell_cmd, "%s %s", cmd, page);
168-
execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL);
168+
execl("/bin/sh", "sh", "-c", shell_cmd.buf, (char *)NULL);
169169
warning("failed to exec '%s': %s", cmd, strerror(errno));
170170
}
171171

@@ -372,7 +372,7 @@ static void show_info_page(const char *git_cmd)
372372
{
373373
const char *page = cmd_to_page(git_cmd);
374374
setenv("INFOPATH", system_path(GIT_INFO_PATH), 1);
375-
execlp("info", "info", "gitman", page, NULL);
375+
execlp("info", "info", "gitman", page, (char *)NULL);
376376
die("no info viewer handled the request");
377377
}
378378

@@ -398,7 +398,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
398398
#ifndef open_html
399399
static void open_html(const char *path)
400400
{
401-
execl_git_cmd("web--browse", "-c", "help.browser", path, NULL);
401+
execl_git_cmd("web--browse", "-c", "help.browser", path, (char *)NULL);
402402
}
403403
#endif
404404

0 commit comments

Comments
 (0)