This is an automated email from Gerrit.

"Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>" just uploaded a new patch 
set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8718

-- gerrit

commit 1ecb2df0de219e7b49d27af4c756a3f1132d6816
Author: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>
Date:   Fri Jan 17 18:03:40 2025 +0300

    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 <evgeniy.nayda...@syntacore.com>
    Helped-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/helper/options.c b/src/helper/options.c
index 61a1014697..a55f49549d 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -21,6 +21,7 @@
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 #if IS_DARWIN
 #include <libproc.h>
 #endif
@@ -303,12 +304,14 @@ 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);
+                               assert(optarg &&
+                                               "'getopt_long()' should require 
an argument for '-l'.");
+                               command_run_linef(cmd_ctx, "log_output %s", 
optarg);
                                break;
                        case 'c':               /* --command | -c */
-                               if (optarg)
-                                   add_config_command(optarg);
+                               assert(optarg &&
+                                               "'getopt_long()' should require 
an argument for '-c'.");
+                               add_config_command(optarg);
                                break;
                        default:  /* '?' */
                                /* getopt will emit an error message, all we 
have to do is bail. */

-- 

Reply via email to