diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/cmd_nvedit.c | 19 | ||||
| -rw-r--r-- | common/console.c | 8 | ||||
| -rw-r--r-- | common/env_common.c | 26 | 
3 files changed, 21 insertions, 32 deletions
| diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 006131f45..a8dc9a694 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;  	} diff --git a/common/console.c b/common/console.c index 25b141a32..c21934d1b 100644 --- a/common/console.c +++ b/common/console.c @@ -681,8 +681,6 @@ int console_init_r(void)  done:  #endif -	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */ -  #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET  	stdio_print_current_devices();  #endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ @@ -694,6 +692,8 @@ done:  	}  #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ +	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */ +  #if 0  	/* If nothing usable installed, use only the initial console */  	if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) @@ -758,8 +758,6 @@ int console_init_r(void)  #endif  	} -	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */ -  #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET  	stdio_print_current_devices();  #endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ @@ -769,6 +767,8 @@ int console_init_r(void)  		setenv(stdio_names[i], stdio_devices[i]->name);  	} +	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */ +  #if 0  	/* If nothing usable installed, use only the initial console */  	if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) diff --git a/common/env_common.c b/common/env_common.c index 3d3cb70a6..f22f5b968 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -83,11 +83,8 @@ const uchar *env_get_addr(int index)  void set_default_env(const char *s)  { -	/* -	 * By default, do not apply changes as they will eventually -	 * be applied by someone else -	 */ -	int do_apply = 0; +	int flags = 0; +  	if (sizeof(default_environment) > ENV_SIZE) {  		puts("*** Error - default environment is too large\n\n");  		return; @@ -99,14 +96,7 @@ void set_default_env(const char *s)  				"using default environment\n\n",  				s + 1);  		} else { -			/* -			 * This set_to_default was explicitly asked for -			 * by the user, as opposed to being a recovery -			 * mechanism.  Therefore we check every single -			 * variable and apply changes to the system -			 * right away (e.g. baudrate, console). -			 */ -			do_apply = 1; +			flags = H_INTERACTIVE;  			puts(s);  		}  	} else { @@ -114,8 +104,8 @@ void set_default_env(const char *s)  	}  	if (himport_r(&env_htab, (char *)default_environment, -			sizeof(default_environment), '\0', 0, -			0, NULL, do_apply) == 0) +			sizeof(default_environment), '\0', flags, +			0, NULL) == 0)  		error("Environment import failed: errno = %d\n", errno);  	gd->flags |= GD_FLG_ENV_READY; @@ -130,8 +120,8 @@ int set_default_vars(int nvars, char * const vars[])  	 * (and use \0 as a separator)  	 */  	return himport_r(&env_htab, (const char *)default_environment, -				sizeof(default_environment), '\0', H_NOCLEAR, -				nvars, vars, 1 /* do_apply */); +				sizeof(default_environment), '\0', +				H_NOCLEAR | H_INTERACTIVE, nvars, vars);  }  #ifndef CONFIG_SPL_BUILD @@ -155,7 +145,7 @@ int env_import(const char *buf, int check)  	}  	if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, -			0, NULL, 0 /* do_apply */)) { +			0, NULL)) {  		gd->flags |= GD_FLG_ENV_READY;  		return 1;  	} |