aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2019-04-05 19:57:29 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2019-04-11 21:08:44 +0200
commitd1b5cf830bfe169745721b21245d2217d2c2453e (patch)
tree3f230490e3ba67789b84f94aebac29370b81092f
parentbb0b10135caf58f82ee9e9d38f400880a7e5c9cc (diff)
build: fix Codacy/CppCheck warnings
- remove unused variables - declare conditionally used variables conditionally - suppress unused variable warnings in the CMake tests - remove dead variable stores - consistently use WIN32 macro to detect Windows Closes https://github.com/curl/curl/pull/3739
-rw-r--r--CMake/CurlTests.c4
-rw-r--r--include/curl/curl.h2
-rw-r--r--lib/asyn-ares.c2
-rw-r--r--lib/if2ip.c7
-rw-r--r--lib/md5.c2
-rw-r--r--lib/timeval.c2
-rw-r--r--lib/version.c2
-rw-r--r--lib/vtls/gskit.c1
-rw-r--r--packages/OS400/os400sys.c1
-rw-r--r--packages/vms/curl_crtl_init.c1
-rw-r--r--src/tool_cb_prg.c2
-rw-r--r--src/tool_cb_wrt.c2
-rw-r--r--src/tool_doswin.c1
-rw-r--r--src/tool_main.c4
-rw-r--r--src/tool_metalink.c4
-rw-r--r--tests/libtest/lib1522.c4
16 files changed, 24 insertions, 17 deletions
diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c
index 0756b2a31..848e0d5d7 100644
--- a/CMake/CurlTests.c
+++ b/CMake/CurlTests.c
@@ -240,6 +240,7 @@ int main()
#ifndef inet_ntoa_r
func_type func;
func = (func_type)inet_ntoa_r;
+ (void)func;
#endif
return 0;
}
@@ -255,6 +256,7 @@ int main()
#ifndef inet_ntoa_r
func_type func;
func = (func_type)&inet_ntoa_r;
+ (void)func;
#endif
return 0;
}
@@ -582,7 +584,9 @@ int fun2(int arg1, int arg2) {
int
main() {
int res3 = c99_vmacro3(1, 2, 3);
+ (void)res3;
int res2 = c99_vmacro2(1, 2);
+ (void)res2;
return 0;
}
#endif
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 86a24184a..b1184fab5 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -114,7 +114,7 @@ typedef void CURLSH;
#ifdef CURL_STATICLIB
# define CURL_EXTERN
-#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__) || \
+#elif defined(WIN32) || defined(__SYMBIAN32__) || \
(__has_declspec_attribute(dllexport) && \
__has_declspec_attribute(dllimport))
# if defined(BUILDING_LIBCURL)
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
index 5e6ba3dd8..fc107bc6b 100644
--- a/lib/asyn-ares.c
+++ b/lib/asyn-ares.c
@@ -68,7 +68,7 @@
#include "progress.h"
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
- (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
+ (defined(WIN32) || defined(__SYMBIAN32__))
# define CARES_STATICLIB
# endif
# include <ares.h>
diff --git a/lib/if2ip.c b/lib/if2ip.c
index acbcff71e..6e27685a0 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -123,7 +123,9 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
char ipstr[64];
#ifdef ENABLE_IPV6
if(af == AF_INET6) {
+#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
unsigned int scopeid = 0;
+#endif
unsigned int ifscope = Curl_ipv6_scope(iface->ifa_addr);
if(ifscope != remote_scope) {
@@ -149,9 +151,10 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
continue;
}
-#endif
+
if(scopeid)
- msnprintf(scope, sizeof(scope), "%%%u", scopeid);
+ msnprintf(scope, sizeof(scope), "%%%u", scopeid);
+#endif
}
else
#endif
diff --git a/lib/md5.c b/lib/md5.c
index db4cc2656..e345065ea 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -124,7 +124,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
CC_MD5_Final(digest, ctx);
}
-#elif defined(_WIN32) && !defined(CURL_WINDOWS_APP)
+#elif defined(WIN32) && !defined(CURL_WINDOWS_APP)
#include <wincrypt.h>
#include "curl_memory.h"
diff --git a/lib/timeval.c b/lib/timeval.c
index ff8d8a69a..e2bd7fd14 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -66,7 +66,9 @@ struct curltime Curl_now(void)
** in any case the time starting point does not change once that the
** system has started up.
*/
+#ifdef HAVE_GETTIMEOFDAY
struct timeval now;
+#endif
struct curltime cnow;
struct timespec tsnow;
diff --git a/lib/version.c b/lib/version.c
index 9369ae8e3..4c885dc33 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -31,7 +31,7 @@
#ifdef USE_ARES
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
- (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
+ (defined(WIN32) || defined(__SYMBIAN32__))
# define CARES_STATICLIB
# endif
# include <ares.h>
diff --git a/lib/vtls/gskit.c b/lib/vtls/gskit.c
index c4afc8904..0498bf05f 100644
--- a/lib/vtls/gskit.c
+++ b/lib/vtls/gskit.c
@@ -1160,7 +1160,6 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex,
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
long timeout_ms;
- Qso_OverlappedIO_t cstat;
CURLcode result = CURLE_OK;
*done = connssl->state == ssl_connection_complete;
diff --git a/packages/OS400/os400sys.c b/packages/OS400/os400sys.c
index c80f01080..84bc10abd 100644
--- a/packages/OS400/os400sys.c
+++ b/packages/OS400/os400sys.c
@@ -389,7 +389,6 @@ Curl_gsk_environment_open(gsk_handle * my_env_handle)
{
struct Curl_gsk_descriptor * p;
- gsk_handle h;
int rc;
if(!my_env_handle)
diff --git a/packages/vms/curl_crtl_init.c b/packages/vms/curl_crtl_init.c
index 01a34e555..7a8d84743 100644
--- a/packages/vms/curl_crtl_init.c
+++ b/packages/vms/curl_crtl_init.c
@@ -183,7 +183,6 @@ static void set_features(void)
status = sys_trnlnm("GNV$UNIX_SHELL",
unix_shell_name, sizeof unix_shell_name -1);
if (!$VMS_STATUS_SUCCESS(status)) {
- unix_shell_name[0] = 0;
use_unix_settings = 0;
}
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c
index 0539e9895..e2ee54225 100644
--- a/src/tool_cb_prg.c
+++ b/src/tool_cb_prg.c
@@ -221,7 +221,7 @@ void progressbarinit(struct ProgressData *bar,
struct winsize ts;
if(!ioctl(STDIN_FILENO, TIOCGWINSZ, &ts))
cols = ts.ws_col;
-#elif defined(_WIN32)
+#elif defined(WIN32)
{
HANDLE stderr_hnd = GetStdHandle(STD_ERROR_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO console_info;
diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c
index f403ab34c..2f699f326 100644
--- a/src/tool_cb_wrt.c
+++ b/src/tool_cb_wrt.c
@@ -159,7 +159,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
}
}
-#ifdef _WIN32
+#ifdef WIN32
fhnd = _get_osfhandle(fileno(outs->stream));
if(isatty(fileno(outs->stream)) &&
GetConsoleScreenBufferInfo((HANDLE)fhnd, &console_info)) {
diff --git a/src/tool_doswin.c b/src/tool_doswin.c
index 8b5bdadaf..779a3cb8f 100644
--- a/src/tool_doswin.c
+++ b/src/tool_doswin.c
@@ -599,7 +599,6 @@ SANITIZEcode rename_if_reserved_dos_device_name(char **const sanitized,
}
memmove(base + 1, base, blen + 1);
base[0] = '_';
- ++blen;
}
}
#endif
diff --git a/src/tool_main.c b/src/tool_main.c
index 5679f361e..7d1e62b79 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -237,7 +237,7 @@ static void main_free(struct GlobalConfig *config)
config->last = NULL;
}
-#ifdef _WIN32
+#ifdef WIN32
/* TerminalSettings for Windows */
static struct TerminalSettings {
HANDLE hStdOut;
@@ -275,7 +275,7 @@ static void configure_terminal(void)
static void restore_terminal(void)
{
-#ifdef _WIN32
+#ifdef WIN32
/* Restore Console output mode and codepage to whatever they were
* when Curl started */
SetConsoleMode(TerminalSettings.hStdOut, TerminalSettings.dwOutputMode);
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index 4c4261472..28aa71707 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -73,7 +73,7 @@
and later. If you're building for an older cat, well, sorry. */
# define COMMON_DIGEST_FOR_OPENSSL
# include <CommonCrypto/CommonDigest.h>
-#elif defined(_WIN32)
+#elif defined(WIN32)
/* For Windows: If no other crypto library is provided, we fallback
to the hash functions provided within the Microsoft Windows CryptoAPI */
# include <wincrypt.h>
@@ -380,7 +380,7 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
sha256_finish(ctx, digest);
}
-#elif defined(_WIN32)
+#elif defined(WIN32)
static void win32_crypto_final(struct win32_crypto_hash *ctx,
unsigned char *digest,
diff --git a/tests/libtest/lib1522.c b/tests/libtest/lib1522.c
index 2de955284..6ac2f9358 100644
--- a/tests/libtest/lib1522.c
+++ b/tests/libtest/lib1522.c
@@ -32,14 +32,16 @@ static char g_Data[40 * 1024]; /* POST 40KB */
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
curlsocktype purpose)
{
+#if defined(SOL_SOCKET) && defined(SO_SNDBUF)
int sndbufsize = 4 * 1024; /* 4KB send buffer */
(void) clientp;
(void) purpose;
-#if defined(SOL_SOCKET) && defined(SO_SNDBUF)
setsockopt(curlfd, SOL_SOCKET, SO_SNDBUF,
(const char *)&sndbufsize, sizeof(sndbufsize));
#else
+ (void)clientp;
(void)curlfd;
+ (void)purpose;
#endif
return CURL_SOCKOPT_OK;
}