]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cookies: Move failure case label to end of function
authorDaniel Gustafsson <daniel@yesql.se>
Sun, 9 Sep 2018 22:20:34 +0000 (00:20 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 Sep 2018 06:33:08 +0000 (08:33 +0200)
Rather than jumping backwards to where failure cleanup happens
to be performed, move the failure case to end of the function
where it is expected per existing coding convention.

Closes #2965

lib/cookie.c

index 732ba9b835293510a90a5effee1693f457cef997..5b7ab6633753cedec842f4f53fbb4f3a994337af 100644 (file)
@@ -1262,12 +1262,8 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
 
             matches++;
           }
-          else {
-            fail:
-            /* failure, clear up the allocated chain and return NULL */
-            Curl_cookie_freelist(mainco);
-            return NULL;
-          }
+          else
+            goto fail;
         }
       }
     }
@@ -1305,6 +1301,11 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
   }
 
   return mainco; /* return the new list */
+
+fail:
+  /* failure, clear up the allocated chain and return NULL */
+  Curl_cookie_freelist(mainco);
+  return NULL;
 }
 
 /*****************************************************************************