X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Fcommand.c;h=f7ec0e21faf4ef929aed457cc22154de8f4a5a02;hb=712c1244e8486bb4519ad0144a03c3c48c030214;hp=96023336c9bafe743a300c2d36371824916a7dda;hpb=5e1468da186e65029316a359493e2d2353e21512;p=openocd.git diff --git a/src/helper/command.c b/src/helper/command.c index 96023336c9..f7ec0e21fa 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -161,15 +161,13 @@ static void script_command_args_free(char **words, unsigned nwords) free(words); } -static char **script_command_args_alloc( - unsigned argc, Jim_Obj * const *argv, unsigned *nwords) +static char **script_command_args_alloc(unsigned int argc, Jim_Obj * const *argv) { char **words = malloc(argc * sizeof(char *)); if (!words) return NULL; - unsigned i; - for (i = 0; i < argc; i++) { + for (unsigned int i = 0; i < argc; i++) { const char *w = Jim_GetString(argv[i], NULL); words[i] = strdup(w); if (!words[i]) { @@ -177,7 +175,6 @@ static char **script_command_args_alloc( return NULL; } } - *nwords = i; return words; } @@ -901,8 +898,8 @@ static int exec_command(Jim_Interp *interp, struct command_context *cmd_ctx, return c->jim_handler(interp, argc, argv); /* use c->handler */ - unsigned int nwords; - char **words = script_command_args_alloc(argc, argv, &nwords); + unsigned int nwords = argc; + char **words = script_command_args_alloc(argc, argv); if (!words) return JIM_ERR;