Fixes warnings found by Clang static analyser
Also removes annotations in the code to avoid warnings which don't appear to
be needed.
diff --git a/library/havege.c b/library/havege.c
index 7623bc0..2b75ef7 100644
--- a/library/havege.c
+++ b/library/havege.c
@@ -174,6 +174,8 @@
PTX = U1 = 0;
PTY = U2 = 0;
+ (void)PTX;
+
memset( RES, 0, sizeof( RES ) );
while( n < MBEDTLS_HAVEGE_COLLECT_SIZE * 4 )
diff --git a/library/rsa.c b/library/rsa.c
old mode 100644
new mode 100755
index 79f86c3..e26d0df
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -804,12 +804,7 @@
int ret;
size_t ilen, pad_count = 0, i;
unsigned char *p, bad, pad_done = 0;
-#if defined(__clang_analyzer__)
- /* Shut up Clang, mbedtls_rsa_public/private writes to this */
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE] = { };
-#else
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-#endif
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
@@ -1193,12 +1188,7 @@
size_t slen, msb;
const mbedtls_md_info_t *md_info;
mbedtls_md_context_t md_ctx;
-#if defined(__clang_analyzer__)
- /* Shut up Clang, mbedtls_rsa_public/private writes to this */
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE] = { };
-#else
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-#endif
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
@@ -1340,12 +1330,7 @@
mbedtls_md_type_t msg_md_alg;
const mbedtls_md_info_t *md_info;
mbedtls_asn1_buf oid;
-#if defined(__clang_analyzer__)
- /* Shut up Clang, mbedtls_rsa_public/private writes to this */
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE] = { };
-#else
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-#endif
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function
index f182485..ac5322e 100644
--- a/tests/suites/main_test.function
+++ b/tests/suites/main_test.function
@@ -83,6 +83,7 @@
return( 1 );
DEP_CHECK_CODE
+#line !LINE_NO! "main_test.function"
return( DEPENDENCY_NOT_SUPPORTED );
}
@@ -96,8 +97,12 @@
#if defined(TEST_SUITE_ACTIVE)
ret = DISPATCH_TEST_SUCCESS;
+ // Cast to void to avoid compiler warnings
+ (void)ret;
+
DISPATCH_FUNCTION
{
+#line !LINE_NO! "main_test.function"
mbedtls_fprintf( stdout,
"FAILED\nSkipping unknown test function '%s'\n",
params[0] );