From 10db3ef21eef1c7a1727579952a81ced2f4afc8b Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Sat, 11 May 2019 21:42:48 +0200 Subject: lib: reduce variable scopes Fixes Codacy/CppCheck warnings. Closes https://github.com/curl/curl/pull/3872 --- lib/transfer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/transfer.c') diff --git a/lib/transfer.c b/lib/transfer.c index 60ad1bb7e..514330e8c 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -157,15 +157,8 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, size_t buffersize = bytes; size_t nread; -#ifndef CURL_DISABLE_HTTP - struct curl_slist *trailers = NULL; - CURLcode c; - int trailers_ret_code; -#endif - curl_read_callback readfunc = NULL; void *extra_data = NULL; - bool added_crlf = FALSE; #ifdef CURL_DOES_CONVERSIONS bool sending_http_headers = FALSE; @@ -182,6 +175,10 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, #ifndef CURL_DISABLE_HTTP if(data->state.trailers_state == TRAILERS_INITIALIZED) { + struct curl_slist *trailers = NULL; + CURLcode c; + int trailers_ret_code; + /* at this point we already verified that the callback exists so we compile and store the trailers buffer, then proceed */ infof(data, @@ -296,7 +293,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, here, knowing they'll become CRLFs later on. */ - char hexbuffer[11] = ""; + bool added_crlf = FALSE; int hexlen = 0; const char *endofline_native; const char *endofline_network; @@ -317,6 +314,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, /* if we're not handling trailing data, proceed as usual */ if(data->state.trailers_state != TRAILERS_SENDING) { + char hexbuffer[11] = ""; hexlen = msnprintf(hexbuffer, sizeof(hexbuffer), "%zx%s", nread, endofline_native); -- cgit v1.2.1