Skip to content

Commit 1696d72

Browse files
Ramsay Jonesgitster
authored andcommitted
compat/mingw.[ch]: Change return type of exec functions to int
The POSIX standard specifies a return type of int for all six exec functions. In addition, all exec functions return -1 on error, and simply do not return on success. However, the current emulation of the exec functions on mingw are declared with a void return type. This would cause a problem should any code attempt to call the exec function in a non-void context. In particular, if an exec function were used in a conditional it would fail to compile. In order to improve the fidelity of the emulation, we change the return type of the mingw_execv[p] functions to int and return -1 on error. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 828ea97 commit 1696d72

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

compat/mingw.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ static void mingw_execve(const char *cmd, char *const *argv, char *const *env)
10031003
}
10041004
}
10051005

1006-
void mingw_execvp(const char *cmd, char *const *argv)
1006+
int mingw_execvp(const char *cmd, char *const *argv)
10071007
{
10081008
char **path = get_path_split();
10091009
char *prog = path_lookup(cmd, path, 0);
@@ -1015,11 +1015,13 @@ void mingw_execvp(const char *cmd, char *const *argv)
10151015
errno = ENOENT;
10161016

10171017
free_path_split(path);
1018+
return -1;
10181019
}
10191020

1020-
void mingw_execv(const char *cmd, char *const *argv)
1021+
int mingw_execv(const char *cmd, char *const *argv)
10211022
{
10221023
mingw_execve(cmd, argv, environ);
1024+
return -1;
10231025
}
10241026

10251027
int mingw_kill(pid_t pid, int sig)

compat/mingw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ int mingw_utime(const char *file_name, const struct utimbuf *times);
274274
pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
275275
const char *dir,
276276
int fhin, int fhout, int fherr);
277-
void mingw_execvp(const char *cmd, char *const *argv);
277+
int mingw_execvp(const char *cmd, char *const *argv);
278278
#define execvp mingw_execvp
279-
void mingw_execv(const char *cmd, char *const *argv);
279+
int mingw_execv(const char *cmd, char *const *argv);
280280
#define execv mingw_execv
281281

282282
static inline unsigned int git_ntohl(unsigned int x)

0 commit comments

Comments
 (0)