[PATCH] env: remove vars that are not in default env
Simon Glass
sjg at chromium.org
Fri Aug 9 17:58:12 CEST 2024
Hi Ravi,
On Fri, 9 Aug 2024 at 09:38, Ravi Minnikanti <rminnikanti at marvell.com> wrote:
>
>
> 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()
>
> Test:
>
> 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: rminnikanti <rminnikanti at marvell.com>
> ---
> env/common.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
Could you add to usage/environment.rst and also update the tests for
this - test/env/ - I suppose your patch fixes a bug, but it is hard to
figure out what it is supposed to do from the docs.
See for example dm_test_acpi_cmd_set() for how to check output from a command.
>
> diff --git a/env/common.c b/env/common.c
> index 8d47d72605..2f783e3a69 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);
> --
> 2.25.1
Regards,
Simon
More information about the U-Boot
mailing list