diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-03-31 09:53:36 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-03-31 10:10:58 +0200 |
commit | b3912d9dd730b468fd7862e5f47e569dd9976f11 (patch) | |
tree | 811fa77d7d9d3cd9293cbdcd7a17b3582c11feaa /lib/file.c | |
parent | 4dae049157102c47b11a3bea19f06819a1e42d6c (diff) | |
download | curl-b3912d9dd730b468fd7862e5f47e569dd9976f11.tar.gz |
file: remove duplicate checks of the same variable
... as it doesn't change in between. Deteced by PVS Studio.
Reported-by: Alexis La Goutte
Diffstat (limited to 'lib/file.c')
-rw-r--r-- | lib/file.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/file.c b/lib/file.c index 5c31fc4f7..e4079054c 100644 --- a/lib/file.c +++ b/lib/file.c @@ -469,6 +469,9 @@ static CURLcode file_do(struct connectdata *conn, bool *done) information. Which for FILE can't be much more than the file size and date. */ if(data->set.opt_no_body && data->set.include_header && fstated) { + time_t filetime; + struct tm buffer; + const struct tm *tm = &buffer; snprintf(buf, sizeof(data->state.buffer), "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size); result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); @@ -480,29 +483,24 @@ static CURLcode file_do(struct connectdata *conn, bool *done) if(result) return result; - if(fstated) { - time_t filetime = (time_t)statbuf.st_mtime; - struct tm buffer; - const struct tm *tm = &buffer; - result = Curl_gmtime(filetime, &buffer); - if(result) - return result; - - /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ - snprintf(buf, BUFSIZE-1, - "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", - Curl_wkday[tm->tm_wday?tm->tm_wday-1:6], - tm->tm_mday, - Curl_month[tm->tm_mon], - tm->tm_year + 1900, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); - result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); - } - /* if we fstat()ed the file, set the file size to make it available post- - transfer */ - if(fstated) + filetime = (time_t)statbuf.st_mtime; + result = Curl_gmtime(filetime, &buffer); + if(result) + return result; + + /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ + snprintf(buf, BUFSIZE-1, + "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", + Curl_wkday[tm->tm_wday?tm->tm_wday-1:6], + tm->tm_mday, + Curl_month[tm->tm_mon], + tm->tm_year + 1900, + tm->tm_hour, + tm->tm_min, + tm->tm_sec); + result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); + if(!result) + /* set the file size to make it available post transfer */ Curl_pgrsSetDownloadSize(data, expected_size); return result; } |