]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_getparam: remove two nextarg NULL checks
authorDaniel Stenberg <daniel@haxx.se>
Thu, 29 May 2025 08:45:52 +0000 (10:45 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 29 May 2025 09:54:49 +0000 (11:54 +0200)
Because by checking for NULL when the argument can never be NULL, they
mislead the static analyzers into thinking it *can* be NULL and then the
analyzers tend to warn about other places in the code *without* the
check!

Closes #17483

src/tool_getparam.c

index 08b1167f1930d9fa23d84dea92a1157026010e82..39defe9e31e65b6d8964cd98acd5fa533436ec9a 100644 (file)
@@ -509,14 +509,13 @@ static void
 GetFileAndPassword(const char *nextarg, char **file, char **password)
 {
   char *certname, *passphrase;
-  if(nextarg) {
-    parse_cert_parameter(nextarg, &certname, &passphrase);
-    free(*file);
-    *file = certname;
-    if(passphrase) {
-      free(*password);
-      *password = passphrase;
-    }
+  /* nextarg is never NULL here */
+  parse_cert_parameter(nextarg, &certname, &passphrase);
+  free(*file);
+  *file = certname;
+  if(passphrase) {
+    free(*password);
+    *password = passphrase;
   }
 }
 
@@ -1090,7 +1089,8 @@ static ParameterError parse_url(struct GlobalConfig *global,
                                 struct OperationConfig *config,
                                 const char *nextarg)
 {
-  if(nextarg && (nextarg[0] == '@')) {
+  /* nextarg is never NULL here */
+  if(nextarg[0] == '@') {
     /* read URLs from a file, treat all as -O */
     struct dynbuf line;
     ParameterError err = PARAM_OK;