Skip to content

Commit

Permalink
Remove path argument from cmd_execute()
Browse files Browse the repository at this point in the history
It is always equal to argv[0] (or not used on Windows).
  • Loading branch information
rom1v committed Nov 27, 2019
1 parent 8dc11a0 commit 73e8ec1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/src/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions app/src/sys/unix/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions app/src/sys/win/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 73e8ec1

Please sign in to comment.