]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
conncache: make Curl_cpool_init return void
authorDaniel Stenberg <daniel@haxx.se>
Thu, 3 Apr 2025 08:48:25 +0000 (10:48 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 3 Apr 2025 11:37:17 +0000 (13:37 +0200)
Since it cannot fail, removing the return code simplifies the code paths
calling this function.

Closes #16936

lib/conncache.c
lib/conncache.h
lib/multi.c
lib/share.c

index cf2807882dc1c88d3ec40ee6ffcea130e645a88a..fe0b07dcb7c5d6294e45152ea477b85eb671ac0f 100644 (file)
@@ -132,10 +132,10 @@ static void cpool_bundle_free_entry(void *freethis)
   cpool_bundle_destroy((struct cpool_bundle *)freethis);
 }
 
-int Curl_cpool_init(struct cpool *cpool,
-                    struct Curl_easy *idata,
-                    struct Curl_share *share,
-                    size_t size)
+void Curl_cpool_init(struct cpool *cpool,
+                     struct Curl_easy *idata,
+                     struct Curl_share *share,
+                     size_t size)
 {
   Curl_hash_init(&cpool->dest2bundle, size, Curl_hash_str,
                  Curl_str_key_compare, cpool_bundle_free_entry);
@@ -145,7 +145,6 @@ int Curl_cpool_init(struct cpool *cpool,
   cpool->idata = idata;
   cpool->share = share;
   cpool->initialised = TRUE;
-  return 0; /* good */
 }
 
 /* Return the "first" connection in the pool or NULL. */
index d8b90c0f4a899aa2a90d07029df1569f08a2370c..bafcc58165e965c840778fff114819cafd1802c8 100644 (file)
@@ -62,12 +62,12 @@ struct cpool {
 };
 
 /* Init the pool, pass multi only if pool is owned by it.
- * returns 1 on error, 0 is fine.
+ * Cannot fail.
  */
-int Curl_cpool_init(struct cpool *cpool,
-                    struct Curl_easy *idata,
-                    struct Curl_share *share,
-                    size_t size);
+void Curl_cpool_init(struct cpool *cpool,
+                     struct Curl_easy *idata,
+                     struct Curl_share *share,
+                     size_t size);
 
 /* Destroy all connections and free all members */
 void Curl_cpool_destroy(struct cpool *connc);
index 858704bebaa44fcb1cf1577afdf322ca6408af0a..9f439652e2701b318781914a8c337eb4f38f9609 100644 (file)
@@ -242,8 +242,7 @@ struct Curl_multi *Curl_multi_handle(size_t ev_hashsize,  /* event hash */
   if(Curl_cshutdn_init(&multi->cshutdn, multi))
     goto error;
 
-  if(Curl_cpool_init(&multi->cpool, multi->admin, NULL, chashsize))
-    goto error;
+  Curl_cpool_init(&multi->cpool, multi->admin, NULL, chashsize);
 
   if(Curl_ssl_scache_create(sesssize, 2, &multi->ssl_scache))
     goto error;
index 110adef68e1935da352d27f30e5a0a53c9b5d7c8..ba3b4ae5afb2ec9e1dd08e934ada35605ef2a62e 100644 (file)
@@ -136,8 +136,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
     case CURL_LOCK_DATA_CONNECT:
       /* It is safe to set this option several times on a share. */
       if(!share->cpool.initialised) {
-        if(Curl_cpool_init(&share->cpool, share->admin, share, 103))
-          res = CURLSHE_NOMEM;
+        Curl_cpool_init(&share->cpool, share->admin, share, 103);
       }
       break;