From: Antonio Borneo Date: Sat, 8 Jun 2019 15:29:58 +0000 (+0200) Subject: helper/options: simplify the code using command_run_linef() X-Git-Tag: v0.11.0-rc1~610 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=a521d93b7a2763a9dcc50e8cae0f037a24f4bfa1 helper/options: simplify the code using command_run_linef() Thanks to command_run_linef() there is no need to pre-build the command using alloc_printf(). Change-Id: Iccfebd6063d1ac162f090fe2309b1f51bebf0214 Signed-off-by: Antonio Borneo Reviewed-on: http://openocd.zylin.com/5226 Tested-by: jenkins Reviewed-by: Tomas Vanek --- diff --git a/src/helper/options.c b/src/helper/options.c index 12755e010a..b60d58de8c 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -269,19 +269,14 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) break; case 'd': /* --debug | -d */ { - char *command = alloc_printf("debug_level %s", optarg ? optarg : "3"); - int retval = command_run_line(cmd_ctx, command); - free(command); + int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3"); if (retval != ERROR_OK) return retval; break; } case 'l': /* --log_output | -l */ - if (optarg) { - char *command = alloc_printf("log_output %s", optarg); - command_run_line(cmd_ctx, command); - free(command); - } + if (optarg) + command_run_linef(cmd_ctx, "log_output %s", optarg); break; case 'c': /* --command | -c */ if (optarg)