diff options
author | Ravi Minnikanti <rminnikanti@marvell.com> | 2024-08-11 11:44:15 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-08-15 11:50:47 -0600 |
commit | 2a521d01e62c012f627d426a4c43082b6402928d (patch) | |
tree | afba443f98d983bd7055818e4d8aed761ea8454f /env/common.c | |
parent | dbb6b5a01098ea2b981cc35d21edd52d33b03f50 (diff) |
env: remove vars that are not in default env
current env_set_default_vars() doesn't delete
var that are not in the imported env. hashtable
removes vars that are not in the imported
env but present in the current env only if H_NOCLEAR
flag is not set.
This change is to avoid passing H_NOCLEAR flag if
specific vars are passed to env_set_default_vars()
Without this change:
Marvell>> env default boot_mode
Marvell>>
With the change:
Marvell>> env default boot_mode
WARNING: 'boot_mode' not in imported env, deleting it!
Signed-off-by: Ravi Minnikanti <rminnikanti@marvell.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'env/common.c')
-rw-r--r-- | env/common.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/env/common.c b/env/common.c index 8d47d726059..6cba7f1c187 100644 --- a/env/common.c +++ b/env/common.c @@ -401,7 +401,15 @@ int env_set_default_vars(int nvars, char * const vars[], int flags) * Special use-case: import from default environment * (and use \0 as a separator) */ - flags |= H_NOCLEAR | H_DEFAULT; + + /* + * When vars are passed remove variables that are not in + * the default environment. + */ + if (!nvars) + flags |= H_NOCLEAR; + + flags |= H_DEFAULT; return himport_r(&env_htab, default_environment, sizeof(default_environment), '\0', flags, 0, nvars, vars); |