diff --git a/src/ssl.c b/src/ssl.c index 634d9c671..1014a826f 100644 --- a/src/ssl.c +++ b/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 diff --git a/src/tls.c b/src/tls.c index d4fc99803..30677592f 100644 --- a/src/tls.c +++ b/src/tls.c @@ -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) { diff --git a/tests/api.c b/tests/api.c index 5d7607f41..8866a9bae 100644 --- a/tests/api.c +++ b/tests/api.c @@ -29,8 +29,6 @@ | Includes *----------------------------------------------------------------------------*/ -#ifndef __clang_analyzer__ - #ifdef HAVE_CONFIG_H #include #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__ */ diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 0cda0de44..2bd4eb8ad 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -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) { diff --git a/wolfcrypt/src/chacha.c b/wolfcrypt/src/chacha.c index e043b5d06..cc5a5a7d1 100644 --- a/wolfcrypt/src/chacha.c +++ b/wolfcrypt/src/chacha.c @@ -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); diff --git a/wolfcrypt/src/pkcs12.c b/wolfcrypt/src/pkcs12.c index ddd9b635c..5ea4dec78 100644 --- a/wolfcrypt/src/pkcs12.c +++ b/wolfcrypt/src/pkcs12.c @@ -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; diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 5481e40ba..40ed69fb5 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -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; diff --git a/wolfcrypt/src/srp.c b/wolfcrypt/src/srp.c index b4fe17c3c..d61e728e1 100644 --- a/wolfcrypt/src/srp.c +++ b/wolfcrypt/src/srp.c @@ -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; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 48b818a63..41bea4efc 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -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); diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 7bf8a95ed..9ccecff1a 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -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) && \