setenv: do console redirection even if previously unset
If "stdout" is not previously set, doing "setenv stdout lcd" had no effect, since console redirection only worked if the environment variable was already set; the second time you run setenv it worked. Most default environments lack stdin/out/err definitions, so I'm sure I'm not alone with this problem. This patch simply moves a block of code out of a conditional, to do the same work even if the variable was previously unset. Signed-off-by: Alessandro Rubini <rubini@unipv.it> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
This commit is contained in:

committed by
Wolfgang Denk

parent
c9ee39972a
commit
9c5586aa19
@@ -202,33 +202,6 @@ int _do_setenv (int flag, int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete any existing definition
|
||||
*/
|
||||
if (oldval >= 0) {
|
||||
#ifndef CONFIG_ENV_OVERWRITE
|
||||
|
||||
/*
|
||||
* Ethernet Address and serial# can be set only once,
|
||||
* ver is readonly.
|
||||
*/
|
||||
if (
|
||||
#ifdef CONFIG_HAS_UID
|
||||
/* Allow serial# forced overwrite with 0xdeaf4add flag */
|
||||
((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
|
||||
#else
|
||||
(strcmp (name, "serial#") == 0) ||
|
||||
#endif
|
||||
((strcmp (name, "ethaddr") == 0)
|
||||
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
|
||||
&& (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
|
||||
#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
|
||||
) ) {
|
||||
printf ("Can't overwrite \"%s\"\n", name);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check for console redirection */
|
||||
if (strcmp(name,"stdin") == 0) {
|
||||
console = stdin;
|
||||
@@ -260,6 +233,33 @@ int _do_setenv (int flag, int argc, char *argv[])
|
||||
#endif /* CONFIG_CONSOLE_MUX */
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete any existing definition
|
||||
*/
|
||||
if (oldval >= 0) {
|
||||
#ifndef CONFIG_ENV_OVERWRITE
|
||||
|
||||
/*
|
||||
* Ethernet Address and serial# can be set only once,
|
||||
* ver is readonly.
|
||||
*/
|
||||
if (
|
||||
#ifdef CONFIG_HAS_UID
|
||||
/* Allow serial# forced overwrite with 0xdeaf4add flag */
|
||||
((strcmp (name, "serial#") == 0) && (flag != 0xdeaf4add)) ||
|
||||
#else
|
||||
(strcmp (name, "serial#") == 0) ||
|
||||
#endif
|
||||
((strcmp (name, "ethaddr") == 0)
|
||||
#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
|
||||
&& (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
|
||||
#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
|
||||
) ) {
|
||||
printf ("Can't overwrite \"%s\"\n", name);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Switch to new baudrate if new baudrate is supported
|
||||
*/
|
||||
|
Reference in New Issue
Block a user