Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

curl_share_setopt: use va_end()

As spotted by Coverity, va_end() was not used previously. To make it
used I took away a bunch of return statements and made them into
assignments instead.
  • Loading branch information...
commit 3da2c0f6d231dabcf0f4402eadc14d954b88a858 1 parent ac3e356
Daniel Stenberg authored June 15, 2012

Showing 1 changed file with 21 additions and 15 deletions. Show diff stats Hide diff stats

  1. 36  lib/share.c
36  lib/share.c
@@ -51,6 +51,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
51 51
   curl_lock_function lockfunc;
52 52
   curl_unlock_function unlockfunc;
53 53
   void *ptr;
  54
+  CURLSHcode res = CURLSHE_OK;
54 55
 
55 56
   if(share->dirty)
56 57
     /* don't allow setting options while one or more handles are already
@@ -69,7 +70,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
69 70
       if(!share->hostcache) {
70 71
         share->hostcache = Curl_mk_dnscache();
71 72
         if(!share->hostcache)
72  
-          return CURLSHE_NOMEM;
  73
+          res = CURLSHE_NOMEM;
73 74
       }
74 75
       break;
75 76
 
@@ -78,12 +79,12 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
78 79
       if(!share->cookies) {
79 80
         share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE );
80 81
         if(!share->cookies)
81  
-          return CURLSHE_NOMEM;
  82
+          res = CURLSHE_NOMEM;
82 83
       }
83  
-      break;
84 84
 #else   /* CURL_DISABLE_HTTP */
85  
-      return CURLSHE_NOT_BUILT_IN;
  85
+      res = CURLSHE_NOT_BUILT_IN;
86 86
 #endif
  87
+      break;
87 88
 
88 89
     case CURL_LOCK_DATA_SSL_SESSION:
89 90
 #ifdef USE_SSL
@@ -93,17 +94,18 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
93 94
                                    sizeof(struct curl_ssl_session));
94 95
         share->sessionage = 0;
95 96
         if(!share->sslsession)
96  
-          return CURLSHE_NOMEM;
  97
+          res = CURLSHE_NOMEM;
97 98
       }
98  
-      break;
99 99
 #else
100  
-      return CURLSHE_NOT_BUILT_IN;
  100
+      res = CURLSHE_NOT_BUILT_IN;
101 101
 #endif
  102
+      break;
102 103
 
103 104
     case CURL_LOCK_DATA_CONNECT:     /* not supported (yet) */
  105
+      break;
104 106
 
105 107
     default:
106  
-      return CURLSHE_BAD_OPTION;
  108
+      res = CURLSHE_BAD_OPTION;
107 109
     }
108 110
     break;
109 111
 
@@ -125,24 +127,25 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
125 127
         Curl_cookie_cleanup(share->cookies);
126 128
         share->cookies = NULL;
127 129
       }
128  
-      break;
129 130
 #else   /* CURL_DISABLE_HTTP */
130  
-      return CURLSHE_NOT_BUILT_IN;
  131
+      res = CURLSHE_NOT_BUILT_IN;
131 132
 #endif
  133
+      break;
132 134
 
133 135
     case CURL_LOCK_DATA_SSL_SESSION:
134 136
 #ifdef USE_SSL
135 137
       Curl_safefree(share->sslsession);
136  
-      break;
137 138
 #else
138  
-      return CURLSHE_NOT_BUILT_IN;
  139
+      res = CURLSHE_NOT_BUILT_IN;
139 140
 #endif
  141
+      break;
140 142
 
141 143
     case CURL_LOCK_DATA_CONNECT:
142 144
       break;
143 145
 
144 146
     default:
145  
-      return CURLSHE_BAD_OPTION;
  147
+      res = CURLSHE_BAD_OPTION;
  148
+      break;
146 149
     }
147 150
     break;
148 151
 
@@ -162,10 +165,13 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
162 165
     break;
163 166
 
164 167
   default:
165  
-    return CURLSHE_BAD_OPTION;
  168
+    res = CURLSHE_BAD_OPTION;
  169
+    break;
166 170
   }
167 171
 
168  
-  return CURLSHE_OK;
  172
+  va_end(param);
  173
+
  174
+  return res;
169 175
 }
170 176
 
171 177
 CURLSHcode

0 notes on commit 3da2c0f

Please sign in to comment.
Something went wrong with that request. Please try again.