common: env: initialize scalar variable
authorPeng Fan <peng.fan@nxp.com>
Wed, 23 Dec 2015 04:07:24 +0000 (12:07 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 4 Jan 2016 17:25:35 +0000 (12:25 -0500)
Before calling hsearch_r, initialize callback entry to NULL.

Coverity log:
"
Uninitialized scalar variable (UNINIT)
uninit_use_in_call: Using uninitialized value e.
Field e.callback is uninitialized when calling hsearch_r.
"

Reported-by: Coverity
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
common/env_callback.c
common/env_flags.c

index f4d3dbd77fa6c311d16927dc517960d26c533a2c..1957cc199648b715a0d7ef81fe614fa775a590db 100644 (file)
@@ -97,6 +97,7 @@ static int set_callback(const char *name, const char *value, void *priv)
 
        e.key   = name;
        e.data  = NULL;
+       e.callback = NULL;
        hsearch_r(e, FIND, &ep, &env_htab, 0);
 
        /* does the env variable actually exist? */
index e682d8517890cca27d87d812244e16330071e783..771935508cb352b6d4f6a9a55c8042e51ba8a749 100644 (file)
@@ -455,6 +455,7 @@ static int set_flags(const char *name, const char *value, void *priv)
 
        e.key   = name;
        e.data  = NULL;
+       e.callback = NULL;
        hsearch_r(e, FIND, &ep, &env_htab, 0);
 
        /* does the env variable actually exist? */