From 778d2dc4bb982ffa00f5fbd343346555fcbf9113 Mon Sep 17 00:00:00 2001 From: Evgeniy Naydanov Date: Fri, 17 Jan 2025 18:03:40 +0300 Subject: [PATCH] helper/options: drop redundant argument checks In case the option is passed with a single `:` in `optstring` argument, the call to `getopt_long()` should return `?`. Therefore the check on `optarg` is redundand in case of `l` and `c`. Change-Id: I1ac176fdae449a34db0a0496b69a9ea65ccd6aec Signed-off-by: Evgeniy Naydanov Reported-by: Antonio Borneo Reviewed-on: https://review.openocd.org/c/openocd/+/8718 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/helper/options.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/helper/options.c b/src/helper/options.c index 61a101469..9e332cc8c 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -303,12 +303,10 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) break; } case 'l': /* --log_output | -l */ - if (optarg) - command_run_linef(cmd_ctx, "log_output %s", optarg); + command_run_linef(cmd_ctx, "log_output %s", optarg); break; case 'c': /* --command | -c */ - if (optarg) - add_config_command(optarg); + add_config_command(optarg); break; default: /* '?' */ /* getopt will emit an error message, all we have to do is bail. */