Skip to content

Commit

Permalink
compat/mingw.[ch]: Change return type of exec functions to int
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Ramsay Jones authored and gitster committed Apr 5, 2012
1 parent 828ea97 commit 1696d72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ static void mingw_execve(const char *cmd, char *const *argv, char *const *env)
}
}

void mingw_execvp(const char *cmd, char *const *argv)
int mingw_execvp(const char *cmd, char *const *argv)
{
char **path = get_path_split();
char *prog = path_lookup(cmd, path, 0);
Expand All @@ -1015,11 +1015,13 @@ void mingw_execvp(const char *cmd, char *const *argv)
errno = ENOENT;

free_path_split(path);
return -1;
}

void mingw_execv(const char *cmd, char *const *argv)
int mingw_execv(const char *cmd, char *const *argv)
{
mingw_execve(cmd, argv, environ);
return -1;
}

int mingw_kill(pid_t pid, int sig)
Expand Down
4 changes: 2 additions & 2 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ int mingw_utime(const char *file_name, const struct utimbuf *times);
pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
const char *dir,
int fhin, int fhout, int fherr);
void mingw_execvp(const char *cmd, char *const *argv);
int mingw_execvp(const char *cmd, char *const *argv);
#define execvp mingw_execvp
void mingw_execv(const char *cmd, char *const *argv);
int mingw_execv(const char *cmd, char *const *argv);
#define execv mingw_execv

static inline unsigned int git_ntohl(unsigned int x)
Expand Down

0 comments on commit 1696d72

Please sign in to comment.