From a521d93b7a2763a9dcc50e8cae0f037a24f4bfa1 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 8 Jun 2019 17:29:58 +0200 Subject: [PATCH] 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 --- src/helper/options.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/helper/options.c b/src/helper/options.c index 12755e010..b60d58de8 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)