From a8d8425ec6f2b75c59562b6e9a7508ab623a2cd4 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sat, 17 Nov 2007 21:07:32 +0100 Subject: [PATCH] Fix prototypes for mingw_execve and mingw_execvp to match Posix This changes the prototypes to match http://www.opengroup.org/onlinepubs/7990989775/xsh/exec.html [js: updated message] Signed-off-by: Steffen Prohaska Signed-off-by: Johannes Sixt --- compat/mingw.c | 19 ++++++++++--------- git-compat-util.h | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index b18231e903..ad44c86a98 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -352,7 +352,7 @@ static const char *quote_arg(const char *arg) return q; } -void quote_argv(const char **dst, const char **src) +void quote_argv(const char **dst, const char *const *src) { while (*src) *dst++ = quote_arg(*src++); @@ -394,7 +394,7 @@ const char *parse_interpreter(const char *cmd) return p+1; } -static int try_shell_exec(const char *cmd, const char **argv, const char **env) +static int try_shell_exec(const char *cmd, char *const *argv, char *const *env) { const char **sh_argv; int n; @@ -412,14 +412,14 @@ static int try_shell_exec(const char *cmd, const char **argv, const char **env) sh_argv = xmalloc((n+2)*sizeof(char*)); sh_argv[0] = interpr; sh_argv[1] = quote_arg(cmd); - quote_argv(&sh_argv[2], &argv[1]); - n = spawnvpe(_P_WAIT, interpr, sh_argv, env); + quote_argv(&sh_argv[2], (const char *const *)&argv[1]); + n = spawnvpe(_P_WAIT, interpr, sh_argv, (const char *const *)env); if (n == -1) return 1; /* indicate that we tried but failed */ exit(n); } -void mingw_execve(const char *cmd, const char **argv, const char **env) +void mingw_execve(const char *cmd, char *const *argv, char *const *env) { /* check if git_command is a shell script */ if (!try_shell_exec(cmd, argv, env)) { @@ -427,8 +427,9 @@ void mingw_execve(const char *cmd, const char **argv, const char **env) int n; for (n = 0; argv[n];) n++; qargv = xmalloc((n+1)*sizeof(char*)); - quote_argv(qargv, argv); - int ret = spawnve(_P_WAIT, cmd, qargv, env); + quote_argv(qargv, (const char *const *)argv); + int ret = spawnve(_P_WAIT, cmd, qargv, + (const char *const *)env); if (ret != -1) exit(ret); } @@ -522,13 +523,13 @@ void mingw_free_path_split(char **path) free(path); } -void mingw_execvp(const char *cmd, const char **argv) +void mingw_execvp(const char *cmd, char *const *argv) { char **path = mingw_get_path_split(); char *prog = mingw_path_lookup(cmd, path); if (prog) { - mingw_execve(prog, argv, (const char **) environ); + mingw_execve(prog, argv, environ); free(prog); } else errno = ENOENT; diff --git a/git-compat-util.h b/git-compat-util.h index 768e7fc696..c88186d685 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -451,9 +451,9 @@ static inline int kill(pid_t pid, int sig) static inline unsigned int alarm(unsigned int seconds) { return 0; } -void mingw_execve(const char *cmd, const char **argv, const char **env); +void mingw_execve(const char *cmd, char *const *argv, char * const *env); #define execve mingw_execve -extern void mingw_execvp(const char *cmd, const char **argv); +extern void mingw_execvp(const char *cmd, char *const *argv); #define execvp mingw_execvp typedef int pid_t; static inline int waitpid(pid_t pid, unsigned *status, unsigned options) @@ -527,7 +527,7 @@ static inline int getppid(void) { return 1; } static inline void sync(void) {} extern int getpagesize(void); /* defined in MinGW's libgcc.a */ -extern void quote_argv(const char **dst, const char **src); +extern void quote_argv(const char **dst, const char *const *src); extern const char *parse_interpreter(const char *cmd); extern char *mingw_path_lookup(const char *cmd, char **path); extern char **mingw_get_path_split(void);