public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd_nvedit.c: setenv_hex must prefix hex with '0x'
Date: Fri,  4 Oct 2013 11:49:18 -0400	[thread overview]
Message-ID: <1380901758-30360-1-git-send-email-trini@ti.com> (raw)

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

             reply	other threads:[~2013-10-04 15:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-04 15:49 Tom Rini [this message]
2013-10-04 21:35 ` [U-Boot] [PATCH] cmd_nvedit.c: setenv_hex must prefix hex with '0x' 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380901758-30360-1-git-send-email-trini@ti.com \
    --to=trini@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox