]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
sendf: remove unnecessary if condition
authorJoel Depooter <joel.depooter@safe.com>
Wed, 26 Oct 2022 00:12:30 +0000 (17:12 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 26 Oct 2022 09:48:59 +0000 (11:48 +0200)
At this point, the psnd->buffer will always exist. We have already
allocated a new buffer if one did not previously exist, and returned
from the function if the allocation failed.

Closes #9801

lib/sendf.c

index d26b7e7cd794dee355efd966ffe3dc23e9ae628c..ad978d10ce03e247f4039ca15c48b6d08f1e8916 100644 (file)
@@ -151,6 +151,8 @@ static CURLcode pre_receive_plain(struct Curl_easy *data,
   const curl_socket_t sockfd = conn->sock[num];
   struct postponed_data * const psnd = &(conn->postponed[num]);
   size_t bytestorecv = psnd->allocated_size - psnd->recv_size;
+  ssize_t recvedbytes;
+
   /* WinSock will destroy unread received data if send() is
      failed.
      To avoid lossage of received data, recv() must be
@@ -176,16 +178,12 @@ static CURLcode pre_receive_plain(struct Curl_easy *data,
 #endif /* DEBUGBUILD */
         bytestorecv = psnd->allocated_size;
       }
-      if(psnd->buffer) {
-        ssize_t recvedbytes;
-        DEBUGASSERT(psnd->bindsock == sockfd);
-        recvedbytes = sread(sockfd, psnd->buffer + psnd->recv_size,
-                            bytestorecv);
-        if(recvedbytes > 0)
-          psnd->recv_size += recvedbytes;
-      }
-      else
-        psnd->allocated_size = 0;
+
+      DEBUGASSERT(psnd->bindsock == sockfd);
+      recvedbytes = sread(sockfd, psnd->buffer + psnd->recv_size,
+                          bytestorecv);
+      if(recvedbytes > 0)
+        psnd->recv_size += recvedbytes;
     }
   }
   return CURLE_OK;