Remove path argument from cmd_execute()

It is always equal to argv[0] (or not used on Windows).
This commit is contained in:
Romain Vimont 2019-11-27 13:41:47 +01:00
parent 8dc11a0286
commit 73e8ec1b35
4 changed files with 5 additions and 6 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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 {

View file

@ -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));