From e83b2c2a50bb0beadb86832f564a2d1c357f0413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 18 Jun 2019 11:31:59 +0200 Subject: [PATCH] Fix unused variable warnings in pkparse.c In a reduced configuration without PEM, PKCS5 or PKCS12, armc5 found that ret was set but not used. Fixing that lead to a new warning about the variable not being used at all. Now the variable is only declared when it's needed. --- library/pkparse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/pkparse.c b/library/pkparse.c index ae210bca6..4ec63e4bb 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -1164,7 +1164,11 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen ) { +#if defined(MBEDTLS_PKCS12_C) || \ + defined(MBEDTLS_PKCS5_C) || \ + defined(MBEDTLS_PEM_PARSE_C) int ret; +#endif const mbedtls_pk_info_t *pk_info; #if defined(MBEDTLS_PEM_PARSE_C) size_t len; @@ -1327,7 +1331,7 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, } #endif /* MBEDTLS_PKCS12_C || MBEDTLS_PKCS5_C */ - if( ( ret = pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen ) ) == 0 ) + if( pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen ) == 0 ) return( 0 ); mbedtls_pk_free( pk );