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:
Marcel Raad 2019-04-05 19:57:29 +02:00
parent bb0b10135c
commit d1b5cf830b
No known key found for this signature in database
GPG key ID: FE4D8BC5EE1701DD
16 changed files with 24 additions and 17 deletions

View file

@ -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;

View file

@ -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)) {

View file

@ -599,7 +599,6 @@ SANITIZEcode rename_if_reserved_dos_device_name(char **const sanitized,
}
memmove(base + 1, base, blen + 1);
base[0] = '_';
++blen;
}
}
#endif

View file

@ -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);

View file

@ -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,