]> granicus.if.org Git - curl/commit
multi: clarify condition in curl_multi_wait
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Sat, 22 Apr 2017 20:16:44 +0000 (21:16 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 22 Apr 2017 20:35:46 +0000 (22:35 +0200)
commitbe299a4dba0362940062f7f07c76862ecf226522
tree334ad7fec4e9d609ff79f8553748cddbca681756
parent4a8cf6c4044a1692b441b64a52d1750a92b798ee
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
lib/multi.c