summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2016-01-14 17:14:00 +0800
committerguoyin.chen <guoyin.chen@freescale.com>2016-03-04 15:53:38 +0800
commit0b2918d4a14e8a9ed83406d89624ae2442ec20b7 (patch)
tree94845484c2af0a1b9ec29c7799044f9cf3c98be9
parent58b76def496c69cd3eb03f114da24b3dd5a380c1 (diff)
downloadu-boot-imx-0b2918d4a14e8a9ed83406d89624ae2442ec20b7.zip
u-boot-imx-0b2918d4a14e8a9ed83406d89624ae2442ec20b7.tar.gz
u-boot-imx-0b2918d4a14e8a9ed83406d89624ae2442ec20b7.tar.bz2
MLK-12199 common:env fix unintialized scalar value
Reported by coverity ID: 17900 17902 Using uninitialized value e. Field e.flags is uninitialized when calling hsearch_r Signed-off-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r--common/cmd_nvedit.c10
-rw-r--r--common/env_callback.c1
-rw-r--r--common/env_flags.c1
3 files changed, 11 insertions, 1 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index c4194d5..6ff041b 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -5,7 +5,7 @@
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Andreas Heppel <aheppel@sysgo.de>
*
- * Copyright 2011-2014 Freescale Semiconductor, Inc.
+ * Copyright (C) 2011-2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -90,6 +90,8 @@ static int env_print(char *name, int flag)
e.key = name;
e.data = NULL;
+ e.callback = NULL;
+ e.flags = 0;
hsearch_r(e, FIND, &ep, &env_htab, flag);
if (ep == NULL)
return 0;
@@ -271,6 +273,8 @@ static int _do_env_set(int flag, int argc, char * const argv[])
e.key = name;
e.data = value;
+ e.callback = NULL;
+ e.flags = 0;
hsearch_r(e, ENTER, &ep, &env_htab, env_flag);
free(value);
if (!ep) {
@@ -615,6 +619,8 @@ char *getenv(const char *name)
e.key = name;
e.data = NULL;
+ e.callback = NULL;
+ e.flags = 0;
hsearch_r(e, FIND, &ep, &env_htab, 0);
return ep ? ep->data : NULL;
@@ -1089,6 +1095,8 @@ static int do_env_exists(cmd_tbl_t *cmdtp, int flag, int argc,
e.key = argv[1];
e.data = NULL;
+ e.callback = NULL;
+ e.flags = 0;
hsearch_r(e, FIND, &ep, &env_htab, 0);
return (ep == NULL) ? 1 : 0;
diff --git a/common/env_callback.c b/common/env_callback.c
index 7de88fb..c7f002a 100644
--- a/common/env_callback.c
+++ b/common/env_callback.c
@@ -98,6 +98,7 @@ static int set_callback(const char *name, const char *value)
e.key = name;
e.data = NULL;
e.callback = NULL;
+ e.flags = 0;
hsearch_r(e, FIND, &ep, &env_htab, 0);
/* does the env variable actually exist? */
diff --git a/common/env_flags.c b/common/env_flags.c
index 815aff9..471973a 100644
--- a/common/env_flags.c
+++ b/common/env_flags.c
@@ -442,6 +442,7 @@ static int set_flags(const char *name, const char *value)
e.key = name;
e.data = NULL;
e.callback = NULL;
+ e.flags = 0;
hsearch_r(e, FIND, &ep, &env_htab, 0);
/* does the env variable actually exist? */