]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
bufq: simplify since expression is always true
authorDaniel Stenberg <daniel@haxx.se>
Thu, 13 Apr 2023 11:43:18 +0000 (13:43 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 14 Apr 2023 07:28:33 +0000 (09:28 +0200)
The check for 'len' is already done so it will remain true until
updated. Pointed out by PVS.

Ref: #10929
Closes #10958

lib/bufq.c

index 5f4ac46bfd626ab4abe6ec96ca2c962dc80b11b3..b598c9081e90d2386d4ac0beca4bf5c755ac3ed0 100644 (file)
@@ -524,22 +524,20 @@ ssize_t Curl_bufq_write_pass(struct bufq *q,
       }
     }
 
-    if(len) {
-      /* Add whatever is remaining now to bufq */
-      n = Curl_bufq_write(q, buf, len, err);
-      if(n < 0) {
-        if(*err != CURLE_AGAIN) {
-          /* real error, fail */
-          return -1;
-        }
-        /* no room in bufq, bail out */
-        goto out;
+    /* Add whatever is remaining now to bufq */
+    n = Curl_bufq_write(q, buf, len, err);
+    if(n < 0) {
+      if(*err != CURLE_AGAIN) {
+        /* real error, fail */
+        return -1;
       }
-      /* Maybe only part of `data` has been added, continue to loop */
-      buf += (size_t)n;
-      len -= (size_t)n;
-      nwritten += (size_t)n;
+      /* no room in bufq, bail out */
+      goto out;
     }
+    /* Maybe only part of `data` has been added, continue to loop */
+    buf += (size_t)n;
+    len -= (size_t)n;
+    nwritten += (size_t)n;
   }
 
 out: