summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>2017-04-22 21:16:44 +0100
committerDaniel Stenberg <daniel@haxx.se>2017-04-22 22:35:46 +0200
commitbe299a4dba0362940062f7f07c76862ecf226522 (patch)
tree334ad7fec4e9d609ff79f8553748cddbca681756
parent4a8cf6c4044a1692b441b64a52d1750a92b798ee (diff)
downloadcurl-be299a4dba0362940062f7f07c76862ecf226522.tar.gz
multi: clarify condition in curl_multi_wait
`if(nfds || extra_nfds) {` is followed by `malloc(nfds * ...)`. If `extra_fs` could be non-zero when `nfds` was zero, then we have `malloc(0)` which is allowed to return `NULL`. But, malloc returning NULL can be confusing. In this code, the next line would treat the NULL as an allocation failure. It turns out, if `nfds` is zero then `extra_nfds` must also be zero. The final value of `nfds` includes `extra_nfds`. So the test for `extra_nfds` is redundant. It can only confuse the reader. Closes #1439
-rw-r--r--lib/multi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/multi.c b/lib/multi.c
index f16776033..26d5f1bd6 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1014,7 +1014,7 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
curlfds = nfds; /* number of internal file descriptors */
nfds += extra_nfds; /* add the externally provided ones */
- if(nfds || extra_nfds) {
+ if(nfds) {
if(nfds > NUM_POLLS_ON_STACK) {
ufds = malloc(nfds * sizeof(struct pollfd));
if(!ufds)