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 <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5226
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
Antonio Borneo 2019-06-08 17:29:58 +02:00 committed by Tomas Vanek
parent 77a8914b7f
commit a521d93b7a

View File

@ -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)