public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd_nvedit.c: setenv_hex must prefix hex with '0x'
@ 2013-10-04 15:49 Tom Rini
  2013-10-04 21:35 ` Wolfgang Denk
  2013-10-05 19:07 ` [U-Boot] [PATCH] Fix number base handling of "load" command Wolfgang Denk
  0 siblings, 2 replies; 10+ messages in thread
From: Tom Rini @ 2013-10-04 15:49 UTC (permalink / raw)
  To: u-boot

setenv_hex is only called with hex values, but does not prefix the
strings with '0x', as in general U-Boot assumes hex values not decimal
values, and this saves space in the environment.  However, some
functions such as 'load' take some values that are most easily described
in hex (load address) and decimal (size, offset within a file).

This can lead to the situation where, for example, spl export is run,
which leads to a call of setenv_hex of the fdtaddr, which will be re-set
in the environment.  Then 'saveenv' may be run (after updating other
parts of the environment for falcon mode), causing an invalid for 'load'
fdtaddr to be saved to the environment and leading to future boots to
fail if using 'load' to read the fdt file.

Cc: Wolfgang Denk <wd@denx.de>
Signed-off-by: Tom Rini <trini@ti.com>
---
 common/cmd_nvedit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 778dca5..4cac794 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -321,7 +321,7 @@ int setenv_hex(const char *varname, ulong value)
 {
 	char str[17];
 
-	sprintf(str, "%lx", value);
+	sprintf(str, "0x%lx", value);
 	return setenv(varname, str);
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-10-07 20:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-04 15:49 [U-Boot] [PATCH] cmd_nvedit.c: setenv_hex must prefix hex with '0x' Tom Rini
2013-10-04 21:35 ` Wolfgang Denk
2013-10-04 21:47   ` Stephen Warren
2013-10-04 22:12     ` Wolfgang Denk
2013-10-04 22:30       ` Stephen Warren
2013-10-05 19:07 ` [U-Boot] [PATCH] Fix number base handling of "load" command Wolfgang Denk
2013-10-07 16:14   ` Stephen Warren
2013-10-07 19:40     ` Wolfgang Denk
2013-10-07 19:42   ` [U-Boot] [PATCH V2] " Wolfgang Denk
2013-10-07 20:04   ` [U-Boot] [PATCH] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox