summaryrefslogtreecommitdiff
path: root/common/cmd_nvedit.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:19 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:54 -0700
commitc4e0057fa78ebb524b9241ad7245fcd1074ba414 (patch)
tree5edef36e43886efa384a8fb373263e0a62c228d4 /common/cmd_nvedit.c
parente772cb30f649c1bb8c9cb15e4c05cbf0760f2f61 (diff)
downloadu-boot-imx-c4e0057fa78ebb524b9241ad7245fcd1074ba414.zip
u-boot-imx-c4e0057fa78ebb524b9241ad7245fcd1074ba414.tar.gz
u-boot-imx-c4e0057fa78ebb524b9241ad7245fcd1074ba414.tar.bz2
env: Refactor do_apply to a flag
Use a flag in hsearch_r for insert mode passed from import to allow the behavior be different based on use. Now that "do_check" is called for all imports, ensure console init is complete before updating the console on relocation import Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common/cmd_nvedit.c')
-rw-r--r--common/cmd_nvedit.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 006131f..a8dc9a6 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -116,7 +116,7 @@ static int env_print(char *name)
e.key = name;
e.data = NULL;
- hsearch_r(e, FIND, &ep, &env_htab);
+ hsearch_r(e, FIND, &ep, &env_htab, 0);
if (ep == NULL)
return 0;
len = printf("%s=%s\n", ep->key, ep->data);
@@ -224,7 +224,7 @@ int env_check_apply(const char *name, const char *oldval,
else if (strcmp(name, "stderr") == 0)
console = stderr;
- if (console != -1) {
+ if (console != -1 && (gd->flags & GD_FLG_DEVINIT) != 0) {
if ((newval == NULL) || (*newval == '\0')) {
/* We cannot delete stdin/stdout/stderr */
if ((flag & H_FORCE) == 0)
@@ -344,20 +344,19 @@ static int _do_env_set(int flag, int argc, char * const argv[])
*/
e.key = name;
e.data = NULL;
- hsearch_r(e, FIND, &ep, &env_htab);
+ hsearch_r(e, FIND, &ep, &env_htab, 0);
/*
- * Perform requested checks. Notice how since we are overwriting
- * a single variable, we need to set H_NOCLEAR
+ * Perform requested checks.
*/
- if (env_check_apply(name, ep ? ep->data : NULL, value, H_NOCLEAR)) {
+ if (env_check_apply(name, ep ? ep->data : NULL, value, 0)) {
debug("check function did not approve, refusing\n");
return 1;
}
/* Delete only ? */
if (argc < 3 || argv[2] == NULL) {
- int rc = hdelete_r(name, &env_htab, 0);
+ int rc = hdelete_r(name, &env_htab, H_INTERACTIVE);
return !rc;
}
@@ -384,7 +383,7 @@ static int _do_env_set(int flag, int argc, char * const argv[])
e.key = name;
e.data = value;
- hsearch_r(e, ENTER, &ep, &env_htab);
+ hsearch_r(e, ENTER, &ep, &env_htab, H_INTERACTIVE);
free(value);
if (!ep) {
printf("## Error inserting \"%s\" variable, errno=%d\n",
@@ -552,7 +551,7 @@ char *getenv(const char *name)
e.key = name;
e.data = NULL;
- hsearch_r(e, FIND, &ep, &env_htab);
+ hsearch_r(e, FIND, &ep, &env_htab, 0);
return ep ? ep->data : NULL;
}
@@ -951,7 +950,7 @@ static int do_env_import(cmd_tbl_t *cmdtp, int flag,
}
if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR,
- 0, NULL, 0 /* do_apply */) == 0) {
+ 0, NULL) == 0) {
error("Environment import failed: errno = %d\n", errno);
return 1;
}