Merge pull request #7092 from douzzer/20231224-clang-unreachable-code-aggressive

20231224-clang-unreachable-code-aggressive
pull/7097/head
David Garske 2023-12-26 14:56:42 -08:00 committed by GitHub
commit b8392ef659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 31 deletions

View File

@ -30338,9 +30338,9 @@ int wolfSSL_curve_is_disabled(const WOLFSSL* ssl, word16 curve_id)
}
if (curve_id >= 32) {
/* 0 is for invalid and 1-14 aren't used otherwise. */
return (ssl->disabledCurves & (1 << (curve_id - 32))) != 0;
return (ssl->disabledCurves & (1U << (curve_id - 32))) != 0;
}
return (ssl->disabledCurves & (1 << curve_id)) != 0;
return (ssl->disabledCurves & (1U << curve_id)) != 0;
}
#if (defined(HAVE_ECC) || \

View File

@ -1455,8 +1455,8 @@ exit:
return args.return_code;
#else
return NOT_COMPILED_IN;
(void)argc;
(void)argv;
return NOT_COMPILED_IN;
#endif /* !NO_WOLFSSL_SERVER && !NO_WOLFSSL_CLIENT */
}

View File

@ -200,6 +200,7 @@ int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz)
return 0;
}
#ifndef USE_INTEL_CHACHA_SPEEDUP
/**
* Converts word into bytes with rotations having been done.
*/
@ -228,6 +229,7 @@ static WC_INLINE void wc_Chacha_wordtobyte(word32 x[CHACHA_CHUNK_WORDS],
#endif
}
}
#endif /* !USE_INTEL_CHACHA_SPEEDUP */
#ifdef HAVE_XCHACHA
@ -325,6 +327,7 @@ extern void chacha_encrypt_avx2(ChaCha* ctx, const byte* m, byte* c,
#endif
#ifndef USE_INTEL_CHACHA_SPEEDUP
/**
* Encrypt a stream of bytes
*/
@ -372,6 +375,8 @@ static void wc_Chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c,
ctx->left = CHACHA_CHUNK_BYTES - bytes;
}
}
#endif /* !USE_INTEL_CHACHA_SPEEDUP */
/**
* API to encrypt/decrypt a message of any size.
@ -423,10 +428,10 @@ int wc_Chacha_Process(ChaCha* ctx, byte* output, const byte* input,
chacha_encrypt_x64(ctx, input, output, msglen);
return 0;
}
#endif
#else
wc_Chacha_encrypt_bytes(ctx, input, output, msglen);
return 0;
#endif
}
void wc_Chacha_purge_current_block(ChaCha* ctx) {

View File

@ -356,7 +356,7 @@ static int InitSha256(wc_Sha256* sha256)
intel_flags = cpuid_get_flags();
#ifdef HAVE_INTEL_AVX2
if (1 && IS_INTEL_AVX2(intel_flags)) {
if (IS_INTEL_AVX2(intel_flags)) {
#ifdef HAVE_INTEL_RORX
if (IS_INTEL_BMI2(intel_flags)) {
Transform_Sha256_p = Transform_Sha256_AVX2_RORX;
@ -365,28 +365,30 @@ static int InitSha256(wc_Sha256* sha256)
}
else
#endif
if (1)
{
Transform_Sha256_p = Transform_Sha256_AVX2;
Transform_Sha256_Len_p = Transform_Sha256_AVX2_Len;
Transform_Sha256_is_vectorized = 1;
}
#ifdef HAVE_INTEL_RORX
else {
Transform_Sha256_p = Transform_Sha256_AVX1_RORX;
Transform_Sha256_Len_p = Transform_Sha256_AVX1_RORX_Len;
Transform_Sha256_is_vectorized = 1;
}
#endif
}
else
#endif
#ifdef HAVE_INTEL_AVX1
if (IS_INTEL_AVX1(intel_flags)) {
#ifdef HAVE_INTEL_RORX
if (IS_INTEL_BMI2(intel_flags)) {
Transform_Sha256_p = Transform_Sha256_AVX1_RORX;
Transform_Sha256_Len_p = Transform_Sha256_AVX1_RORX_Len;
Transform_Sha256_is_vectorized = 1;
}
else
#endif
{
Transform_Sha256_p = Transform_Sha256_AVX1;
Transform_Sha256_Len_p = Transform_Sha256_AVX1_Len;
Transform_Sha256_is_vectorized = 1;
}
}
else
#endif
{

View File

@ -452,33 +452,37 @@ static int InitSha512_256(wc_Sha512* sha512)
}
else
#endif
if (1) {
{
Transform_Sha512_p = Transform_Sha512_AVX2;
Transform_Sha512_Len_p = Transform_Sha512_AVX2_Len;
Transform_Sha512_is_vectorized = 1;
}
#ifdef HAVE_INTEL_RORX
else {
Transform_Sha512_p = Transform_Sha512_AVX1_RORX;
Transform_Sha512_Len_p = Transform_Sha512_AVX1_RORX_Len;
Transform_Sha512_is_vectorized = 1;
}
#endif
}
else
#endif
#if defined(HAVE_INTEL_AVX1)
if (IS_INTEL_AVX1(intel_flags)) {
Transform_Sha512_p = Transform_Sha512_AVX1;
Transform_Sha512_Len_p = Transform_Sha512_AVX1_Len;
#ifdef HAVE_INTEL_RORX
if (IS_INTEL_BMI2(intel_flags)) {
Transform_Sha512_p = Transform_Sha512_AVX1_RORX;
Transform_Sha512_Len_p = Transform_Sha512_AVX1_RORX_Len;
Transform_Sha512_is_vectorized = 1;
}
else
#endif
{
Transform_Sha512_p = _Transform_Sha512;
Transform_Sha512_p = Transform_Sha512_AVX1;
Transform_Sha512_Len_p = Transform_Sha512_AVX1_Len;
Transform_Sha512_is_vectorized = 1;
}
}
else
#endif
{
Transform_Sha512_p = _Transform_Sha512;
Transform_Sha512_Len_p = NULL;
Transform_Sha512_is_vectorized = 0;
}
transform_check = 1;
}

View File

@ -6139,9 +6139,15 @@ WOLFSSL_LOCAL int SetECKeyExternal(WOLFSSL_EC_KEY* eckey);
#if defined(OPENSSL_EXTRA) || defined(HAVE_CURL)
WOLFSSL_LOCAL int wolfSSL_curve_is_disabled(const WOLFSSL* ssl,
word16 named_curve);
word16 curve_id);
#else
#define wolfSSL_curve_is_disabled(ssl, c) ((void)(ssl), (void)(c), 0)
static WC_INLINE int wolfSSL_curve_is_disabled(const WOLFSSL* ssl,
word16 curve_id)
{
(void)ssl;
(void)curve_id;
return 0;
}
#endif
WOLFSSL_LOCAL WC_RNG* WOLFSSL_RSA_GetRNG(WOLFSSL_RSA *rsa, WC_RNG **tmpRNG,