The attached patches fix a couple of clang warnings. I think the first one fixes an actual, albeit minor, bug. The other ones mainly fix dead stores and shouldn't result in change of behaviour.
I left a couple of warnings untouched in places were I thought
keeping them would keep the code consistent. An example from
lib/sendf.c is:
131 else {
132 /* copy last byte */
133 *outPtr = *inPtr;
134 }
135 outPtr++;
136 inPtr++;
Value stored to 'inPtr' is never read
Other ones depend on ifdefs and fixing them didn't seem worth it.
For example in lib/version.c (I'm compiling without USE_ARES):
81 #ifdef HAVE_LIBZ1
82 len = snprintfcurl_msnprintf(ptr, left, " zlib/%s", zlibVersion());
83 left -= len;
84 ptr += len;
Value stored to 'ptr' is never read
85 #endif
86 #ifdef USE_ARES
87 /* this function is only present in c-ares, not in the original ares */
88 len = snprintfcurl_msnprintf(ptr, left, " c-ares/%s",
ares_version(NULL((void *)0)));
89 left -= len;
90 ptr += len;
91 #endif
Finally there were a few cases were I wasn't sure what to do,
for example in lib/ftp.c
1829 rc = Curl_resolv(conn, conn->proxy.name, (int)conn->port, &addr);
1830 if(rc == CURLRESOLV_PENDING1)
1831 /* BLOCKING */
1832 rc = Curl_wait_for_resolv(conn, &addr);
Value stored to 'rc' is never read
One could either check rc, or use "(void)Curl_wait_for_resolv(conn, &addr);"
to keep the current behaviour without the dead store. That's a decision for
someone who knows the code, though.
Fabian
From 7dc32c0e490b24659d3a5d9c19df9f4b7ac1c916 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 19:44:30 +0200 Subject: [PATCH 01/10] In Curl_proxyCONNECT(), let the first timeout check return CURLE_RECV_ERROR, like the second one does. error is never read here, so don't set it. --- lib/http.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git lib/http.c lib/http.c index cd2307d..a7e6d4d 100644 --- lib/http.c +++ lib/http.c @@ -1419,8 +1419,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */ if(check <=0 ) { failf(data, "Proxy CONNECT aborted due to timeout"); - error = SELECT_TIMEOUT; /* already too little time */ - break; + return CURLE_RECV_ERROR; } /* if we're in multi-mode and we would block, return instead for a retry */ -- 1.6.3.1
From b2dd1ef177b6b14d341666ab926179f8cc534517 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 19:55:00 +0200 Subject: [PATCH 02/10] Fix white space. --- lib/http.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git lib/http.c lib/http.c index a7e6d4d..82f4ac6 100644 --- lib/http.c +++ lib/http.c @@ -1417,7 +1417,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, /* if timeout is requested, find out how much remaining time we have */ check = timeout - /* timeout time */ Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */ - if(check <=0 ) { + if(check <= 0) { failf(data, "Proxy CONNECT aborted due to timeout"); return CURLE_RECV_ERROR; } -- 1.6.3.1
From 74089ee1ac703538d2965eadfc4365975894cd60 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 19:01:38 +0200 Subject: [PATCH 03/10] Remove dead store. --- src/main.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git src/main.c src/main.c index 9f3970d..901b3ae 100644 --- src/main.c +++ src/main.c @@ -2698,7 +2698,6 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ break; case 'Q': /* QUOTE command to send to FTP server */ - err = PARAM_OK; switch(nextarg[0]) { case '-': /* prefixed with a dash makes it a POST TRANSFER one */ -- 1.6.3.1
From 247acb3806c67f399b832f9abe37344025becff9 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 19:02:44 +0200 Subject: [PATCH 04/10] No need to set i to 0 twice. --- src/main.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git src/main.c src/main.c index 901b3ae..fb2ec7e 100644 --- src/main.c +++ src/main.c @@ -3376,7 +3376,6 @@ static int myprogress (void *clientp, percent = frac * 100.0f; barwidth = bar->width - 7; num = (int) (((double)barwidth) * frac); - i = 0; for ( i = 0; i < num; i++ ) { line[i] = '#'; } -- 1.6.3.1
From be135a51f567f7a63cc048e9697f3a7749a86ae8 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 18:57:37 +0200 Subject: [PATCH 05/10] Remove strange check for NULL. --- lib/cookie.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git lib/cookie.c lib/cookie.c index 026f769..d4b508a 100644 --- lib/cookie.c +++ lib/cookie.c @@ -405,7 +405,7 @@ Curl_cookie_add(struct SessionHandle *data, } ptr=semiptr+1; - while(ptr && *ptr && ISBLANK(*ptr)) + while(*ptr && ISBLANK(*ptr)) ptr++; semiptr=strchr(ptr, ';'); /* now, find the next semicolon */ -- 1.6.3.1
From 92a8c3254454458ff683be91b4cfc2390f712eab Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 20:02:14 +0200 Subject: [PATCH 06/10] No need to initialize tok_start twice. --- lib/url.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git lib/url.c lib/url.c index 80f4f45..0d1d3f8 100644 --- lib/url.c +++ lib/url.c @@ -3489,7 +3489,6 @@ static bool check_noproxy(const char* name, const char* no_proxy) else namelen = strlen(name); - tok_start = 0; for (tok_start = 0; tok_start < no_proxy_len; tok_start = tok_end + 1) { while (tok_start < no_proxy_len && strchr(separator, no_proxy[tok_start]) != NULL) { -- 1.6.3.1
From 851edd758f229f50e637247588370f8f650fe18b Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 20:30:50 +0200 Subject: [PATCH 07/10] Why increment nthdef if we won't read from it. --- lib/dict.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git lib/dict.c lib/dict.c index 2d7e4f2..b4a1294 100644 --- lib/dict.c +++ lib/dict.c @@ -182,7 +182,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done) *strategy++ = (char)0; nthdef = strchr(strategy, ':'); if(nthdef) { - *nthdef++ = (char)0; + *nthdef = (char)0; } } } @@ -238,7 +238,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done) *database++ = (char)0; nthdef = strchr(database, ':'); if(nthdef) { - *nthdef++ = (char)0; + *nthdef = (char)0; } } } -- 1.6.3.1
From 03c4ee2b2522f361414230a3ca0b3fdd12fca6a4 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 20:35:49 +0200 Subject: [PATCH 08/10] Incrementing datap has no effect here, it isn't read before returning. --- lib/http_chunks.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git lib/http_chunks.c lib/http_chunks.c index b4cad61..52ffc7f 100644 --- lib/http_chunks.c +++ lib/http_chunks.c @@ -345,7 +345,6 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, conn->trailer[conn->trlPos]=0; if(conn->trlPos==2) { ch->state = CHUNK_STOP; - datap++; length--; /* @@ -400,7 +399,6 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, case CHUNK_STOP: if(*datap == 0x0a) { - datap++; length--; /* Record the length of any data left in the end of the buffer -- 1.6.3.1
From f091d1b2d23ef868d4e86fa9aaf2b5765d2860c9 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 20:10:25 +0200 Subject: [PATCH 09/10] No need to set timeout_ms to 0, if it's overwritten right away, or never touched again. --- lib/ssluse.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git lib/ssluse.c lib/ssluse.c index a9a8714..acf7529 100644 --- lib/ssluse.c +++ lib/ssluse.c @@ -2272,7 +2272,6 @@ ossl_connect_common(struct connectdata *conn, return retcode; } - timeout_ms = 0; while(ssl_connect_2 == connssl->connecting_state || ssl_connect_2_reading == connssl->connecting_state || ssl_connect_2_writing == connssl->connecting_state) { -- 1.6.3.1
From 38b698b22b3c4945ef9ba07e5acf1968c7d2a9a5 Mon Sep 17 00:00:00 2001 From: Fabian Keil <[email protected]> Date: Mon, 1 Jun 2009 20:15:53 +0200 Subject: [PATCH 10/10] Fix dead store. Either the 'done = 1' or the 'break' are enough to leave the loop. The else block doesn't break, so don't break from the 'else if' block either. --- lib/ssluse.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git lib/ssluse.c lib/ssluse.c index acf7529..9a0f60e 100644 --- lib/ssluse.c +++ lib/ssluse.c @@ -857,7 +857,6 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex) /* timeout */ failf(data, "SSL shutdown timeout"); done = 1; - break; } else { /* anything that gets here is fatally bad */ -- 1.6.3.1
signature.asc
Description: PGP signature
