2009-12-09 11:51:59

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH] crypto/testmgr: fix uninitialized warning from gcc

Since err is not set to a value if tcount is 0, gcc issues a warning:
crypto/testmgr.c: In function ‘test_cprng’:
crypto/testmgr.c:1204: warning: ‘err’ may be used uninitialized in this function

Since this is test code, forcing initialized sanity should be fine.

Signed-off-by: Mike Frysinger <[email protected]>
---
crypto/testmgr.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 7620bfc..90c4254 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1214,6 +1214,7 @@ static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template,
return -ENOMEM;
}

+ err = 0; /* sanity in case tcount is 0 */
for (i = 0; i < tcount; i++) {
memset(result, 0, 32);

--
1.6.5.5


2009-12-11 06:28:19

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto/testmgr: fix uninitialized warning from gcc

On Wed, Dec 09, 2009 at 06:52:04AM -0500, Mike Frysinger wrote:
> Since err is not set to a value if tcount is 0, gcc issues a warning:
> crypto/testmgr.c: In function ‘test_cprng’:
> crypto/testmgr.c:1204: warning: ‘err’ may be used uninitialized in this function
>
> Since this is test code, forcing initialized sanity should be fine.
>
> Signed-off-by: Mike Frysinger <[email protected]>

Thanks but a similar patch has already been merged.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt