From b662cc1f52893f9797060193add61cd6d0a8b8a7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine <Gilles.Peskine@arm.com> Date: Fri, 24 Nov 2017 18:55:19 +0100 Subject: [PATCH] Avoid uninitialized variable warning in entropy_gather_internal The variable ret was always initialized in entropy_gather_internal, but `gcc -Werror=maybe-uninitialized` rightfully complained that it was unable to determine this statically. Therefore, tweak the problematic case (ctx->source_count == 0) to not use ret in that case. --- library/entropy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/entropy.c b/library/entropy.c index 5a8321b8d..518d98215 100644 --- a/library/entropy.c +++ b/library/entropy.c @@ -196,13 +196,11 @@ int entropy_update_manual( entropy_context *ctx, */ static int entropy_gather_internal( entropy_context *ctx ) { - int ret, i; + int ret = POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED; + int i; unsigned char buf[ENTROPY_MAX_GATHER]; size_t olen; - if( ctx->source_count == 0 ) - return( POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED ); - /* * Run through our entropy sources */