From 653a4a2fba9739c7a9e048f2a5a4bbfeb1f4e4c0 Mon Sep 17 00:00:00 2001 From: k-stachowiak Date: Wed, 3 Jul 2019 14:31:09 +0200 Subject: [PATCH] Prevent dead code warning The window size variable in ecp_pick_window_size() can take values 4, 5 or 6, but we clamp it not to exceed the value of MBEDTLS_ECP_WINDOW_SIZE. If that is 6 (default) or higher, the static analyzer will point out that the test: w > MBEDTLS_ECP_WINDOW_SIZE always evaluates to false. This commit removes the test for the cases of the window size large enough to fit all the potential values of the variable. --- library/ecp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/ecp.c b/library/ecp.c index 03f5fefd4..ccc0788c2 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -2004,8 +2004,10 @@ static unsigned char ecp_pick_window_size( const mbedtls_ecp_group *grp, * Make sure w is within bounds. * (The last test is useful only for very small curves in the test suite.) */ +#if( MBEDTLS_ECP_WINDOW_SIZE < 6 ) if( w > MBEDTLS_ECP_WINDOW_SIZE ) w = MBEDTLS_ECP_WINDOW_SIZE; +#endif if( w >= grp->nbits ) w = 2;