mirror of
https://github.com/curl/curl.git
synced 2025-09-17 01:22:41 +03:00
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
This commit is contained in:
parent
bb0b10135c
commit
d1b5cf830b
|
@ -240,6 +240,7 @@ int main()
|
||||||
#ifndef inet_ntoa_r
|
#ifndef inet_ntoa_r
|
||||||
func_type func;
|
func_type func;
|
||||||
func = (func_type)inet_ntoa_r;
|
func = (func_type)inet_ntoa_r;
|
||||||
|
(void)func;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +256,7 @@ int main()
|
||||||
#ifndef inet_ntoa_r
|
#ifndef inet_ntoa_r
|
||||||
func_type func;
|
func_type func;
|
||||||
func = (func_type)&inet_ntoa_r;
|
func = (func_type)&inet_ntoa_r;
|
||||||
|
(void)func;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -582,7 +584,9 @@ int fun2(int arg1, int arg2) {
|
||||||
int
|
int
|
||||||
main() {
|
main() {
|
||||||
int res3 = c99_vmacro3(1, 2, 3);
|
int res3 = c99_vmacro3(1, 2, 3);
|
||||||
|
(void)res3;
|
||||||
int res2 = c99_vmacro2(1, 2);
|
int res2 = c99_vmacro2(1, 2);
|
||||||
|
(void)res2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -114,7 +114,7 @@ typedef void CURLSH;
|
||||||
|
|
||||||
#ifdef CURL_STATICLIB
|
#ifdef CURL_STATICLIB
|
||||||
# define CURL_EXTERN
|
# define CURL_EXTERN
|
||||||
#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__) || \
|
#elif defined(WIN32) || defined(__SYMBIAN32__) || \
|
||||||
(__has_declspec_attribute(dllexport) && \
|
(__has_declspec_attribute(dllexport) && \
|
||||||
__has_declspec_attribute(dllimport))
|
__has_declspec_attribute(dllimport))
|
||||||
# if defined(BUILDING_LIBCURL)
|
# if defined(BUILDING_LIBCURL)
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
|
|
||||||
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
||||||
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
|
(defined(WIN32) || defined(__SYMBIAN32__))
|
||||||
# define CARES_STATICLIB
|
# define CARES_STATICLIB
|
||||||
# endif
|
# endif
|
||||||
# include <ares.h>
|
# include <ares.h>
|
||||||
|
|
|
@ -123,7 +123,9 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||||
char ipstr[64];
|
char ipstr[64];
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
if(af == AF_INET6) {
|
if(af == AF_INET6) {
|
||||||
|
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||||
unsigned int scopeid = 0;
|
unsigned int scopeid = 0;
|
||||||
|
#endif
|
||||||
unsigned int ifscope = Curl_ipv6_scope(iface->ifa_addr);
|
unsigned int ifscope = Curl_ipv6_scope(iface->ifa_addr);
|
||||||
|
|
||||||
if(ifscope != remote_scope) {
|
if(ifscope != remote_scope) {
|
||||||
|
@ -149,9 +151,10 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if(scopeid)
|
if(scopeid)
|
||||||
msnprintf(scope, sizeof(scope), "%%%u", scopeid);
|
msnprintf(scope, sizeof(scope), "%%%u", scopeid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -124,7 +124,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
|
||||||
CC_MD5_Final(digest, ctx);
|
CC_MD5_Final(digest, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(CURL_WINDOWS_APP)
|
#elif defined(WIN32) && !defined(CURL_WINDOWS_APP)
|
||||||
|
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
#include "curl_memory.h"
|
#include "curl_memory.h"
|
||||||
|
|
|
@ -66,7 +66,9 @@ struct curltime Curl_now(void)
|
||||||
** in any case the time starting point does not change once that the
|
** in any case the time starting point does not change once that the
|
||||||
** system has started up.
|
** system has started up.
|
||||||
*/
|
*/
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
#endif
|
||||||
struct curltime cnow;
|
struct curltime cnow;
|
||||||
struct timespec tsnow;
|
struct timespec tsnow;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#ifdef USE_ARES
|
#ifdef USE_ARES
|
||||||
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
|
||||||
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
|
(defined(WIN32) || defined(__SYMBIAN32__))
|
||||||
# define CARES_STATICLIB
|
# define CARES_STATICLIB
|
||||||
# endif
|
# endif
|
||||||
# include <ares.h>
|
# include <ares.h>
|
||||||
|
|
|
@ -1160,7 +1160,6 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex,
|
||||||
struct Curl_easy *data = conn->data;
|
struct Curl_easy *data = conn->data;
|
||||||
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
|
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
|
||||||
long timeout_ms;
|
long timeout_ms;
|
||||||
Qso_OverlappedIO_t cstat;
|
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
*done = connssl->state == ssl_connection_complete;
|
*done = connssl->state == ssl_connection_complete;
|
||||||
|
|
|
@ -389,7 +389,6 @@ Curl_gsk_environment_open(gsk_handle * my_env_handle)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct Curl_gsk_descriptor * p;
|
struct Curl_gsk_descriptor * p;
|
||||||
gsk_handle h;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if(!my_env_handle)
|
if(!my_env_handle)
|
||||||
|
|
|
@ -183,7 +183,6 @@ static void set_features(void)
|
||||||
status = sys_trnlnm("GNV$UNIX_SHELL",
|
status = sys_trnlnm("GNV$UNIX_SHELL",
|
||||||
unix_shell_name, sizeof unix_shell_name -1);
|
unix_shell_name, sizeof unix_shell_name -1);
|
||||||
if (!$VMS_STATUS_SUCCESS(status)) {
|
if (!$VMS_STATUS_SUCCESS(status)) {
|
||||||
unix_shell_name[0] = 0;
|
|
||||||
use_unix_settings = 0;
|
use_unix_settings = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ void progressbarinit(struct ProgressData *bar,
|
||||||
struct winsize ts;
|
struct winsize ts;
|
||||||
if(!ioctl(STDIN_FILENO, TIOCGWINSZ, &ts))
|
if(!ioctl(STDIN_FILENO, TIOCGWINSZ, &ts))
|
||||||
cols = ts.ws_col;
|
cols = ts.ws_col;
|
||||||
#elif defined(_WIN32)
|
#elif defined(WIN32)
|
||||||
{
|
{
|
||||||
HANDLE stderr_hnd = GetStdHandle(STD_ERROR_HANDLE);
|
HANDLE stderr_hnd = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
CONSOLE_SCREEN_BUFFER_INFO console_info;
|
CONSOLE_SCREEN_BUFFER_INFO console_info;
|
||||||
|
|
|
@ -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));
|
fhnd = _get_osfhandle(fileno(outs->stream));
|
||||||
if(isatty(fileno(outs->stream)) &&
|
if(isatty(fileno(outs->stream)) &&
|
||||||
GetConsoleScreenBufferInfo((HANDLE)fhnd, &console_info)) {
|
GetConsoleScreenBufferInfo((HANDLE)fhnd, &console_info)) {
|
||||||
|
|
|
@ -599,7 +599,6 @@ SANITIZEcode rename_if_reserved_dos_device_name(char **const sanitized,
|
||||||
}
|
}
|
||||||
memmove(base + 1, base, blen + 1);
|
memmove(base + 1, base, blen + 1);
|
||||||
base[0] = '_';
|
base[0] = '_';
|
||||||
++blen;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -237,7 +237,7 @@ static void main_free(struct GlobalConfig *config)
|
||||||
config->last = NULL;
|
config->last = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef WIN32
|
||||||
/* TerminalSettings for Windows */
|
/* TerminalSettings for Windows */
|
||||||
static struct TerminalSettings {
|
static struct TerminalSettings {
|
||||||
HANDLE hStdOut;
|
HANDLE hStdOut;
|
||||||
|
@ -275,7 +275,7 @@ static void configure_terminal(void)
|
||||||
|
|
||||||
static void restore_terminal(void)
|
static void restore_terminal(void)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef WIN32
|
||||||
/* Restore Console output mode and codepage to whatever they were
|
/* Restore Console output mode and codepage to whatever they were
|
||||||
* when Curl started */
|
* when Curl started */
|
||||||
SetConsoleMode(TerminalSettings.hStdOut, TerminalSettings.dwOutputMode);
|
SetConsoleMode(TerminalSettings.hStdOut, TerminalSettings.dwOutputMode);
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
and later. If you're building for an older cat, well, sorry. */
|
and later. If you're building for an older cat, well, sorry. */
|
||||||
# define COMMON_DIGEST_FOR_OPENSSL
|
# define COMMON_DIGEST_FOR_OPENSSL
|
||||||
# include <CommonCrypto/CommonDigest.h>
|
# include <CommonCrypto/CommonDigest.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(WIN32)
|
||||||
/* For Windows: If no other crypto library is provided, we fallback
|
/* For Windows: If no other crypto library is provided, we fallback
|
||||||
to the hash functions provided within the Microsoft Windows CryptoAPI */
|
to the hash functions provided within the Microsoft Windows CryptoAPI */
|
||||||
# include <wincrypt.h>
|
# include <wincrypt.h>
|
||||||
|
@ -380,7 +380,7 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
|
||||||
sha256_finish(ctx, digest);
|
sha256_finish(ctx, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(WIN32)
|
||||||
|
|
||||||
static void win32_crypto_final(struct win32_crypto_hash *ctx,
|
static void win32_crypto_final(struct win32_crypto_hash *ctx,
|
||||||
unsigned char *digest,
|
unsigned char *digest,
|
||||||
|
|
|
@ -32,14 +32,16 @@ static char g_Data[40 * 1024]; /* POST 40KB */
|
||||||
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
||||||
curlsocktype purpose)
|
curlsocktype purpose)
|
||||||
{
|
{
|
||||||
|
#if defined(SOL_SOCKET) && defined(SO_SNDBUF)
|
||||||
int sndbufsize = 4 * 1024; /* 4KB send buffer */
|
int sndbufsize = 4 * 1024; /* 4KB send buffer */
|
||||||
(void) clientp;
|
(void) clientp;
|
||||||
(void) purpose;
|
(void) purpose;
|
||||||
#if defined(SOL_SOCKET) && defined(SO_SNDBUF)
|
|
||||||
setsockopt(curlfd, SOL_SOCKET, SO_SNDBUF,
|
setsockopt(curlfd, SOL_SOCKET, SO_SNDBUF,
|
||||||
(const char *)&sndbufsize, sizeof(sndbufsize));
|
(const char *)&sndbufsize, sizeof(sndbufsize));
|
||||||
#else
|
#else
|
||||||
|
(void)clientp;
|
||||||
(void)curlfd;
|
(void)curlfd;
|
||||||
|
(void)purpose;
|
||||||
#endif
|
#endif
|
||||||
return CURL_SOCKOPT_OK;
|
return CURL_SOCKOPT_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user