forked from wolfSSL/wolfssl
scan-build fixes: back out all "#ifndef __clang_analyzer__" wrappers added to suppress false and frivolous positives from alpha.deadcode.UnreachableCode, and rename new macro WC_UNUSED to WC_MAYBE_UNUSED to make its meaning more precisely apparent. build is still clean with -Wunreachable-code-break -Wunreachable-code-return under scan-build-13.
This commit is contained in:
20
src/ssl.c
20
src/ssl.c
@@ -28624,12 +28624,10 @@ int wolfSSL_X509_PUBKEY_set(WOLFSSL_X509_PUBKEY **x, WOLFSSL_EVP_PKEY *key)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
if (!wolfSSL_EVP_PKEY_up_ref(key)) {
|
||||
WOLFSSL_MSG("Failed to up key reference");
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
pk->pkey = key;
|
||||
|
||||
wolfSSL_X509_PUBKEY_free(*x);
|
||||
@@ -31536,12 +31534,10 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_BN_to_ASN1_INTEGER(const WOLFSSL_BIGNUM *bn, WOLFS
|
||||
a = ai;
|
||||
}
|
||||
if (a) {
|
||||
#ifndef __clang_analyzer__
|
||||
if (wolfSSL_BN_is_negative(bn) && !wolfSSL_BN_is_zero(bn)) {
|
||||
a->type |= V_ASN1_NEG_INTEGER;
|
||||
a->negative = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
len = wolfSSL_BN_num_bytes(bn);
|
||||
if (len == 0)
|
||||
@@ -31777,13 +31773,11 @@ int wolfSSL_ASN1_item_i2d(const void *src, byte **dest,
|
||||
if (dest && !*dest) {
|
||||
*dest = buf;
|
||||
}
|
||||
#ifndef __clang_analyzer__
|
||||
else if (dest && *dest && buf) {
|
||||
/* *dest length is not checked because the user is responsible
|
||||
* for providing a long enough buffer */
|
||||
XMEMCPY(*dest, buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
WOLFSSL_LEAVE("wolfSSL_ASN1_item_i2d", len);
|
||||
return len;
|
||||
@@ -54534,13 +54528,11 @@ void wolfSSL_X509V3_set_ctx(WOLFSSL_X509V3_CTX* ctx, WOLFSSL_X509* issuer,
|
||||
if (!ctx || !ctx->x509)
|
||||
return;
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
if (!ctx->x509) {
|
||||
ctx->x509 = wolfSSL_X509_new();
|
||||
if (!ctx->x509)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set parameters in ctx as long as ret == WOLFSSL_SUCCESS */
|
||||
if (issuer)
|
||||
@@ -54622,7 +54614,7 @@ void wolfSSL_X509_REQ_free(WOLFSSL_X509* req)
|
||||
int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey,
|
||||
const WOLFSSL_EVP_MD *md)
|
||||
{
|
||||
WC_UNUSED int ret;
|
||||
WC_MAYBE_UNUSED int ret;
|
||||
byte der[2048];
|
||||
int derSz = sizeof(der);
|
||||
|
||||
@@ -58063,10 +58055,8 @@ void *wolfSSL_BIO_get_ex_data(WOLFSSL_BIO *bio, int idx)
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
PRAGMA_CLANG_DIAG_PUSH
|
||||
PRAGMA_CLANG("clang diagnostic ignored \"-Wformat-nonliteral\"")
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
@@ -58149,8 +58139,8 @@ int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...)
|
||||
}
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
#if !defined(NO_FILESYSTEM) && defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#ifndef NO_FILESYSTEM
|
||||
PRAGMA_CLANG_DIAG_POP
|
||||
#endif
|
||||
|
||||
#undef LINE_LEN
|
||||
|
@@ -10302,12 +10302,10 @@ int TLSX_PopulateExtensions(WOLFSSL* ssl, byte isServer)
|
||||
extension = TLSX_Find(ssl->extensions, TLSX_KEY_SHARE);
|
||||
if (extension == NULL) {
|
||||
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
|
||||
#ifndef __clang_analyzer__
|
||||
if (ssl->options.resuming && ssl->session.namedGroup != 0)
|
||||
namedGroup = ssl->session.namedGroup;
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
PRAGMA_CLANG_DIAG_PUSH
|
||||
PRAGMA_CLANG("clang diagnostic ignored \"-Wunreachable-code-return\"")
|
||||
if (PREFERRED_GROUP_SZ == 0) {
|
||||
|
@@ -29,8 +29,6 @@
|
||||
| Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
@@ -39513,7 +39511,7 @@ static int test_wolfSSL_EVP_Cipher_extra(void)
|
||||
|
||||
int *test_drive[] = {test_drive1, test_drive2, test_drive3, NULL};
|
||||
int test_drive_len[100];
|
||||
WC_UNUSED int drive_len;
|
||||
WC_MAYBE_UNUSED int drive_len;
|
||||
|
||||
int ret = 0;
|
||||
EVP_CIPHER_CTX *evp = NULL;
|
||||
@@ -51085,5 +51083,3 @@ void ApiTest(void)
|
||||
printf(" End API Tests\n");
|
||||
|
||||
}
|
||||
|
||||
#endif /* !__clang_analyzer__ */
|
||||
|
@@ -11141,11 +11141,9 @@ int wc_AesKeyWrap(const byte* key, word32 keySz, const byte* in, word32 inSz,
|
||||
return MEMORY_E;
|
||||
#endif
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
#endif
|
||||
|
||||
ret = wc_AesSetKey(aes, key, keySz, NULL, AES_ENCRYPTION);
|
||||
if (ret != 0) {
|
||||
@@ -11256,11 +11254,9 @@ int wc_AesKeyUnWrap(const byte* key, word32 keySz, const byte* in, word32 inSz,
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
#endif
|
||||
|
||||
ret = wc_AesSetKey(aes, key, keySz, NULL, AES_DECRYPTION);
|
||||
if (ret != 0) {
|
||||
@@ -11313,14 +11309,12 @@ int wc_AesXtsSetKey(XtsAes* aes, const byte* key, word32 len, int dir,
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
if ((ret = wc_AesInit(&aes->tweak, heap, devId)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = wc_AesInit(&aes->aes, heap, devId)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
keySz = len/2;
|
||||
if (keySz != 16 && keySz != 32) {
|
||||
|
@@ -300,10 +300,8 @@ int wc_XChacha_SetKey(ChaCha *ctx,
|
||||
XMEMSET(iv, 0, 4);
|
||||
XMEMCPY(iv + 4, nonce + 16, 8);
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
if ((ret = wc_Chacha_SetIV(ctx, iv, counter)) < 0)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
ForceZero(k, sizeof k);
|
||||
ForceZero(iv, sizeof iv);
|
||||
|
@@ -2280,7 +2280,6 @@ WC_PKCS12* wc_PKCS12_create(char* pass, word32 passSz, char* name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
if ((ret = wc_PKCS12_SetHeap(pkcs12, heap)) != 0) {
|
||||
wc_PKCS12_free(pkcs12);
|
||||
wc_FreeRng(&rng);
|
||||
@@ -2288,7 +2287,6 @@ WC_PKCS12* wc_PKCS12_create(char* pass, word32 passSz, char* name,
|
||||
(void)ret;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (iter <= 0) {
|
||||
iter = WC_PKCS12_ITT_DEFAULT;
|
||||
|
@@ -770,12 +770,10 @@ PKCS7* wc_PKCS7_New(void* heap, int devId)
|
||||
if (wc_PKCS7_Init(pkcs7, heap, devId) == 0) {
|
||||
pkcs7->isDynamic = 1;
|
||||
}
|
||||
#ifndef __clang_analyzer__
|
||||
else {
|
||||
XFREE(pkcs7, heap, DYNAMIC_TYPE_PKCS7);
|
||||
pkcs7 = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return pkcs7;
|
||||
}
|
||||
@@ -1532,9 +1530,6 @@ static int EncodeAttributes(EncodedAttrib* ea, int eaSz,
|
||||
int maxSz = min(eaSz, attribsSz);
|
||||
int allAttribsSz = 0;
|
||||
|
||||
#ifdef __clang_analyzer__
|
||||
assert(maxSz > 0);
|
||||
#endif
|
||||
for (i = 0; i < maxSz; i++)
|
||||
{
|
||||
int attribSz = 0;
|
||||
|
@@ -620,14 +620,12 @@ static int wc_SrpSetKey(Srp* srp, byte* secret, word32 size)
|
||||
if (!r) r = SrpHashUpdate(&hash, counter, 4);
|
||||
|
||||
if (!r) {
|
||||
#ifndef __clang_analyzer__
|
||||
if (j + digestSz > srp->keySz) {
|
||||
r = SrpHashFinal(&hash, digest);
|
||||
XMEMCPY(srp->key + j, digest, srp->keySz - j);
|
||||
j = srp->keySz;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
r = SrpHashFinal(&hash, srp->key + j);
|
||||
j += digestSz;
|
||||
|
@@ -19045,11 +19045,9 @@ WOLFSSL_TEST_SUBROUTINE int openssl_test(void)
|
||||
return -8672;
|
||||
if(outlen != 16)
|
||||
return -8673;
|
||||
#ifndef __clang_analyzer__
|
||||
total += outlen;
|
||||
if(total != 32)
|
||||
return -8674;
|
||||
#endif
|
||||
|
||||
total = 0;
|
||||
EVP_CIPHER_CTX_init(de);
|
||||
@@ -19109,11 +19107,9 @@ WOLFSSL_TEST_SUBROUTINE int openssl_test(void)
|
||||
return -8690;
|
||||
if(outlen != 16)
|
||||
return -8691;
|
||||
#ifndef __clang_analyzer__
|
||||
total += outlen;
|
||||
if(total != 32)
|
||||
return 3438;
|
||||
#endif
|
||||
|
||||
total = 0;
|
||||
EVP_CIPHER_CTX_init(de);
|
||||
|
@@ -330,13 +330,13 @@ decouple library dependencies with standard string, memory and so on.
|
||||
#endif
|
||||
#endif /* WARN_UNUSED_RESULT */
|
||||
|
||||
#ifndef WC_UNUSED
|
||||
#ifndef WC_MAYBE_UNUSED
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
|
||||
#define WC_UNUSED __attribute__((unused))
|
||||
#define WC_MAYBE_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define WC_UNUSED
|
||||
#define WC_MAYBE_UNUSED
|
||||
#endif
|
||||
#endif /* WC_UNUSED */
|
||||
#endif /* WC_MAYBE_UNUSED */
|
||||
|
||||
/* Micrium will use Visual Studio for compilation but not the Win32 API */
|
||||
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
|
||||
|
Reference in New Issue
Block a user