[U-Boot] [PATCH] cmd_nvedit.c: setenv_hex must prefix hex with '0x'

Tom Rini
2013-10-04T15:49:18Z

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