From 2823f6abcc11b1aee2ca568f51e1b8585c74c467 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Thu, 28 Sep 2017 18:59:26 +0200 Subject: [PATCH] fix coverage --- src/ulib/base/zip/ziptool.c | 31 +++++++++++++++---------------- src/ulib/net/client/http.cpp | 7 ++++--- src/ulib/utility/uhttp.cpp | 2 ++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ulib/base/zip/ziptool.c b/src/ulib/base/zip/ziptool.c index 23a44388..2e9f2283 100644 --- a/src/ulib/base/zip/ziptool.c +++ b/src/ulib/base/zip/ziptool.c @@ -804,8 +804,8 @@ unsigned zip_extract(const char* zipfile, const char** files, char*** filenames, { unsigned n = 0; char* names[1024]; - int j, file_num = 0; unsigned names_len[1024]; + int j, file_num = 0, f_fd, handle; U_INTERNAL_TRACE("zip_extract(%s,%p,%p,%p)", zipfile, files, filenames, filenames_len) @@ -818,8 +818,8 @@ unsigned zip_extract(const char* zipfile, const char** files, char*** filenames, for (;;) { - int f_fd = 0, - handle = 1; /* by default we'll extract/create the file */ + f_fd = 0; + handle = 1; /* by default we'll extract/create the file */ U_INTERNAL_ASSERT(n < 1024) @@ -843,15 +843,12 @@ unsigned zip_extract(const char* zipfile, const char** files, char*** filenames, } } - if (handle) + if (handle == 0) f_fd = -1; + else { names[n] = strdup((const char*)filename); names_len[n] = fnlen; } - else - { - f_fd = -1; - } /** * OK, there is some directory information in the file. Nothing to do @@ -859,7 +856,8 @@ unsigned zip_extract(const char* zipfile, const char** files, char*** filenames, * What a pain! */ - if (strchr((const char*)filename, '/') != 0 && handle) + if (handle && + strchr((const char*)filename, '/') != 0) { /* Loop through all the directories in the path, (everything w/ a '/') */ @@ -916,14 +914,15 @@ unsigned zip_extract(const char* zipfile, const char** files, char*** filenames, return 0; } } - else if (S_ISDIR(sbuf.st_mode)) - { - U_INTERNAL_TRACE("Directory exists") - - continue; - } else { + if (S_ISDIR(sbuf.st_mode)) + { + U_INTERNAL_TRACE("Directory exists") + + continue; + } + U_INTERNAL_TRACE("Hmmm.. %s exists but isn't a directory!", tmp_buff) free(tmp_buff); @@ -1006,8 +1005,8 @@ unsigned zip_extract(const char* zipfile, const char** files, char*** filenames, (void) write(f_fd, rd_buff, rdamt); # endif + in_a -= rdamt; out_a += rdamt; - in_a -= rdamt; U_INTERNAL_TRACE("%d bytes written", out_a) } diff --git a/src/ulib/net/client/http.cpp b/src/ulib/net/client/http.cpp index 4c15cd78..f2ffbe31 100644 --- a/src/ulib/net/client/http.cpp +++ b/src/ulib/net/client/http.cpp @@ -947,9 +947,10 @@ bool UHttpClient_Base::sendRequest() if (server_context_flag) { - u_clientimage_info.flag.u = flag_save; - u_clientimage_info.http_info.nResponseCode = U_http_info.nResponseCode; - u_clientimage_info.http_info = http_info_save; + u_clientimage_info.flag.u = flag_save; + + http_info_save.nResponseCode = U_http_info.nResponseCode; + U_http_info = http_info_save; } U_INTERNAL_DUMP("server_context_flag = %b U_ClientImage_close = %b", server_context_flag, U_ClientImage_close) diff --git a/src/ulib/utility/uhttp.cpp b/src/ulib/utility/uhttp.cpp index 90252aeb..1375734e 100644 --- a/src/ulib/utility/uhttp.cpp +++ b/src/ulib/utility/uhttp.cpp @@ -4481,6 +4481,7 @@ file_in_cache: if (checkIfSourceHasChangedAndCompileUSP()) # endif { +# ifndef U_COVERITY_FALSE_POSITIVE // FORWARD_NULL UServletPage* usp = (UServletPage*)file_data->ptr; U_INTERNAL_ASSERT_POINTER(usp) @@ -4491,6 +4492,7 @@ file_in_cache: U_DUMP("U_http_info.nResponseCode = %u", U_http_info.nResponseCode) usp->runDynamicPage(0); +# endif U_DUMP("U_http_info.nResponseCode = %u U_ClientImage_parallelization = %d UClientImage_Base::isNoHeaderForResponse() = %b", U_http_info.nResponseCode, U_ClientImage_parallelization, UClientImage_Base::isNoHeaderForResponse())