]> granicus.if.org Git - curl/commitdiff
Bug #149: Deletion of unnecessary checks before a few calls of cURL functions
authorMarkus Elfring <elfring@users.sourceforge.net>
Wed, 11 Mar 2015 17:15:33 +0000 (18:15 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 16 Mar 2015 11:13:56 +0000 (12:13 +0100)
The following functions return immediately if a null pointer was passed.
* Curl_cookie_cleanup
* curl_formfree

It is therefore not needed that a function caller repeats a corresponding check.

This issue was fixed by using the software Coccinelle 1.0.0-rc24.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
lib/formdata.c
lib/share.c
lib/url.c

index 3f41a427555bf83aa58bdfd4cc22261bbd170da3..3076a14370adb66810738babed05254208904c65 100644 (file)
@@ -969,8 +969,7 @@ void curl_formfree(struct curl_httppost *form)
     next=form->next;  /* the following form line */
 
     /* recurse to sub-contents */
-    if(form->more)
-      curl_formfree(form->more);
+    curl_formfree(form->more);
 
     if(!(form->flags & HTTPPOST_PTRNAME))
       free(form->name); /* free the name */
index b8b6bee8033c42f8a6e099f06676d4e92f263029..3fc53119ec4100a0178a23b388a4ca192b0e29e6 100644 (file)
@@ -198,8 +198,7 @@ curl_share_cleanup(CURLSH *sh)
   }
 
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
-  if(share->cookies)
-    Curl_cookie_cleanup(share->cookies);
+  Curl_cookie_cleanup(share->cookies);
 #endif
 
 #ifdef USE_SSL
index eec11a0e3894f9a66017110ae08e76079f344668..eb98e361b7b068290a6c2ce5cc0a0ec6a11b722d 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2150,8 +2150,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
       if(data->share->cookies) {
         /* use shared cookie list, first free own one if any */
-        if(data->cookies)
-          Curl_cookie_cleanup(data->cookies);
+        Curl_cookie_cleanup(data->cookies);
         /* enable cookies since we now use a share that uses cookies! */
         data->cookies = data->share->cookies;
       }