cppcheck: fix warnings

- Get rid of variable that was generating false positive warning
(unitialized)

- Fix issues in tests

- Reduce scope of several variables all over

etc

Closes #2631
This commit is contained in:
Marian Klymov 2018-06-02 23:52:56 +03:00 committed by Daniel Stenberg
parent 38203f1585
commit c45360d463
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
61 changed files with 213 additions and 273 deletions

View file

@ -80,7 +80,6 @@ int Curl_wait_ms(int timeout_ms)
#endif
struct curltime initial_tv;
int pending_ms;
int error;
#endif
int r = 0;
@ -98,6 +97,7 @@ int Curl_wait_ms(int timeout_ms)
pending_ms = timeout_ms;
initial_tv = Curl_now();
do {
int error;
#if defined(HAVE_POLL_FINE)
r = poll(NULL, 0, pending_ms);
#else
@ -160,7 +160,6 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
#endif
struct curltime initial_tv = {0, 0};
int pending_ms = 0;
int error;
int r;
int ret;
@ -210,6 +209,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
}
do {
int error;
if(timeout_ms < 0)
pending_ms = -1;
else if(!timeout_ms)
@ -291,6 +291,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
int error;
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
@ -402,7 +403,6 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
bool fds_none = TRUE;
unsigned int i;
int pending_ms = 0;
int error;
int r;
if(ufds) {
@ -431,6 +431,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
#ifdef HAVE_POLL_FINE
do {
int error;
if(timeout_ms < 0)
pending_ms = -1;
else if(!timeout_ms)
@ -502,6 +503,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
int error;
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;