]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: nvedit: propagate envflag to set_default_vars
authorYaniv Levinsky <yaniv.levinsky@compulab.co.il>
Sun, 24 Jun 2018 16:16:55 +0000 (19:16 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 19 Jul 2018 20:17:58 +0000 (16:17 -0400)
The env_flag in do_env_default() doesn't get propagated and therefore
gets ignored by himport_r(). This breaks to ability to "forcibly" reset
variables to their default values using the environment command.

Scenario example of the problem:
# setenv kernel uImage
# setenv .flags kernel:so
# env default -f kernel
## Error: Can't overwrite "kernel"
himport_r: can't insert "kernel=zImage" into hash table

Change the call path so it will pass the flag correctly.

Signed-off-by: Yaniv Levinsky <yaniv.levinsky@compulab.co.il>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
cmd/nvedit.c
env/common.c
include/environment.h

index d456d2fc9ba57ee0c65bffb515352ac8866e18f6..1955dee0d0241b0cf519ca4457388c5bdd9fa4e2 100644 (file)
@@ -807,7 +807,7 @@ static int do_env_default(cmd_tbl_t *cmdtp, int flag,
        }
        if (!all && (argc > 0)) {
                /* Reset individual variables */
-               set_default_vars(argc, argv);
+               set_default_vars(argc, argv, env_flag);
                return 0;
        }
 
index dc8a14f519059f3d44c5d1f30609675be8a781a6..6cf5eddaf65353965c36a8eb0df052df9610c515 100644 (file)
@@ -91,15 +91,16 @@ void set_default_env(const char *s)
 
 
 /* [re]set individual variables to their value in the default environment */
-int set_default_vars(int nvars, char * const vars[])
+int 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_INTERACTIVE;
        return himport_r(&env_htab, (const char *)default_environment,
                                sizeof(default_environment), '\0',
-                               H_NOCLEAR | H_INTERACTIVE, 0, nvars, vars);
+                               flags, 0, nvars, vars);
 }
 
 /*
index 70b7eda428b660ca0ed72e7c81b152b80e876b3e..2fe1f3eb4853a0b54e962c5203e69be8409f50eb 100644 (file)
@@ -275,7 +275,7 @@ char *env_get_default(const char *name);
 void set_default_env(const char *s);
 
 /* [re]set individual variables to their value in the default environment */
-int set_default_vars(int nvars, char * const vars[]);
+int set_default_vars(int nvars, char * const vars[], int flags);
 
 /* Import from binary representation into hash table */
 int env_import(const char *buf, int check);