From 0ebf111b37f38dd79e11a0eafd30b3e0f17df9ba Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 13 Apr 2023 13:43:18 +0200 Subject: [PATCH] bufq: simplify since expression is always true 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 | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/bufq.c b/lib/bufq.c index 5f4ac46bfd..b598c9081e 100644 --- a/lib/bufq.c +++ b/lib/bufq.c @@ -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: -- 2.47.3