From 73e8ec1b356eacfc4a77e84fcd4c143727e8eeb0 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 27 Nov 2019 13:41:47 +0100 Subject: [PATCH] Remove path argument from cmd_execute() It is always equal to argv[0] (or not used on Windows). --- app/src/command.c | 2 +- app/src/command.h | 2 +- app/src/sys/unix/command.c | 4 ++-- app/src/sys/win/command.c | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/command.c b/app/src/command.c index 33a9c587..abaa223d 100644 --- a/app/src/command.c +++ b/app/src/command.c @@ -91,7 +91,7 @@ adb_execute(const char *serial, const char *const adb_cmd[], size_t len) { memcpy(&cmd[i], adb_cmd, len * sizeof(const char *)); cmd[len + i] = NULL; - enum process_result r = cmd_execute(cmd[0], cmd, &process); + enum process_result r = cmd_execute(cmd, &process); if (r != PROCESS_SUCCESS) { show_adb_err_msg(r, cmd); return PROCESS_NONE; diff --git a/app/src/command.h b/app/src/command.h index e748c1c5..edbc3fb8 100644 --- a/app/src/command.h +++ b/app/src/command.h @@ -44,7 +44,7 @@ enum process_result { }; enum process_result -cmd_execute(const char *path, const char *const argv[], process_t *process); +cmd_execute(const char *const argv[], process_t *process); bool cmd_terminate(process_t pid); diff --git a/app/src/sys/unix/command.c b/app/src/sys/unix/command.c index 512b9af7..fbcf2355 100644 --- a/app/src/sys/unix/command.c +++ b/app/src/sys/unix/command.c @@ -21,7 +21,7 @@ #include "util/log.h" enum process_result -cmd_execute(const char *path, const char *const argv[], pid_t *pid) { +cmd_execute(const char *const argv[], pid_t *pid) { int fd[2]; if (pipe(fd) == -1) { @@ -52,7 +52,7 @@ cmd_execute(const char *path, const char *const argv[], pid_t *pid) { // child close read side close(fd[0]); if (fcntl(fd[1], F_SETFD, FD_CLOEXEC) == 0) { - execvp(path, (char *const *)argv); + execvp(argv[0], (char *const *)argv); if (errno == ENOENT) { ret = PROCESS_ERROR_MISSING_BINARY; } else { diff --git a/app/src/sys/win/command.c b/app/src/sys/win/command.c index 6cd0e944..55edaf8f 100644 --- a/app/src/sys/win/command.c +++ b/app/src/sys/win/command.c @@ -19,8 +19,7 @@ build_cmd(char *cmd, size_t len, const char *const argv[]) { } enum process_result -cmd_execute(const char *path, const char *const argv[], HANDLE *handle) { - (void) path; +cmd_execute(const char *const argv[], HANDLE *handle) { STARTUPINFOW si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si));