diff mbox series

[07/11] env: gd flags without ENV_READY is enough to discriminate in

Message ID e4ddde03fb8e39a18f92485e6b9da2e69d9ef3f7.1513975247.git-series.quentin.schulz@free-electrons.com
State New
Headers show
Series Introduce variables whitelisting in environment | expand

Commit Message

Quentin Schulz Dec. 22, 2017, 9:13 p.m. UTC
env_get_default

To prepare the removal of env_valid in an upcoming patch, and since the
ENV_READY flag in gd is enough to discriminate in env_get_char, let's
update env_get_char to return the variable in the default environment
when ENV_READY flag is not set and remove env_valid setting and getting
from env_get_default.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 env/common.c | 3 ---
 env/env.c    | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/env/common.c b/env/common.c
index c8d8993..75b8334 100644
--- a/env/common.c
+++ b/env/common.c
@@ -47,14 +47,11 @@  int env_get_yesno(const char *var)
 char *env_get_default(const char *name)
 {
 	char *ret_val;
-	unsigned long really_valid = gd->env_valid;
 	unsigned long real_gd_flags = gd->flags;
 
 	/* Pretend that the image is bad. */
 	gd->flags &= ~GD_FLG_ENV_READY;
-	gd->env_valid = ENV_INVALID;
 	ret_val = env_get(name);
-	gd->env_valid = really_valid;
 	gd->flags = real_gd_flags;
 	return ret_val;
 }
diff --git a/env/env.c b/env/env.c
index 7c98083..2565e7a 100644
--- a/env/env.c
+++ b/env/env.c
@@ -141,7 +141,7 @@  int env_get_char(int index)
 	struct env_driver *drv;
 	int prio;
 
-	if (gd->env_valid == ENV_INVALID)
+	if (!(gd->flags & GD_FLG_ENV_READY))
 		return default_environment[index];
 
 	for (prio = 0; (drv = env_driver_lookup(ENVO_GET_CHAR, prio)); prio++) {