Skip to content

Commit

Permalink
Remove unnecessary argc parameter from run_command_v.
Browse files Browse the repository at this point in the history
The argc parameter is never used by the run_command_v family of
functions.  Instead they require that the passed argv[] be NULL
terminated so they can rely on the operating system's execvp
function to correctly pass the arguments to the new process.

Making the caller pass the argc is just confusing, as the caller
could be mislead into believing that the argc might take precendece
over the argv, or that the argv does not need to be NULL terminated.
So goodbye argc.  Don't come back.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Dec 31, 2006
1 parent ad1a382 commit 9b0b509
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion builtin-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static int do_push(const char *repo)
argv[dest_argc] = NULL;
if (verbose)
fprintf(stderr, "Pushing to %s\n", dest);
err = run_command_v(argc, argv);
err = run_command_v(argv);
if (!err)
continue;
switch (err) {
Expand Down
4 changes: 2 additions & 2 deletions receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void run_update_post_hook(struct command *cmd)
argc++;
}
argv[argc] = NULL;
run_command_v_opt(argc, argv, RUN_COMMAND_NO_STDIO);
run_command_v_opt(argv, RUN_COMMAND_NO_STDIO);
}

/*
Expand Down Expand Up @@ -283,7 +283,7 @@ static const char *unpack(void)
unpacker[0] = "unpack-objects";
unpacker[1] = hdr_arg;
unpacker[2] = NULL;
code = run_command_v_opt(1, unpacker, RUN_GIT_CMD);
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
switch (code) {
case 0:
return NULL;
Expand Down
8 changes: 4 additions & 4 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "run-command.h"
#include "exec_cmd.h"

int run_command_v_opt(int argc, const char **argv, int flags)
int run_command_v_opt(const char **argv, int flags)
{
pid_t pid = fork();

Expand Down Expand Up @@ -46,9 +46,9 @@ int run_command_v_opt(int argc, const char **argv, int flags)
}
}

int run_command_v(int argc, const char **argv)
int run_command_v(const char **argv)
{
return run_command_v_opt(argc, argv, 0);
return run_command_v_opt(argv, 0);
}

int run_command(const char *cmd, ...)
Expand All @@ -69,5 +69,5 @@ int run_command(const char *cmd, ...)
va_end(param);
if (MAX_RUN_COMMAND_ARGS <= argc)
return error("too many args to run %s", cmd);
return run_command_v_opt(argc, argv, 0);
return run_command_v_opt(argv, 0);
}
4 changes: 2 additions & 2 deletions run-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ enum {

#define RUN_COMMAND_NO_STDIO 1
#define RUN_GIT_CMD 2 /*If this is to be git sub-command */
int run_command_v_opt(int argc, const char **argv, int opt);
int run_command_v(int argc, const char **argv);
int run_command_v_opt(const char **argv, int opt);
int run_command_v(const char **argv);
int run_command(const char *cmd, ...);

#endif

0 comments on commit 9b0b509

Please sign in to comment.