Skip to contentSkip to conversation

cmd_nvedit.c: make error message more helpful

PATCH New Wolfgang Denk 1 participant 2 messages May 4, 2011 – May 12, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd_nvedit.c: make error message more helpful

When calling getenv_f() with a too small buffer, it would print an error message like this:

env_buf too small [32]

This is not really helpful as it does not give any indication which of the calls might have failed. Change this into:

env_buf [32 bytes] too small for value of "hwconfig"

so we know at least which variable caused the overflow; this usually allows to quickly find the related code as well.

---
 common/cmd_nvedit.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
common/cmd_nvedit.c +2 -1
index aa9de3a..b2c88ba 100644
@@ -532,7 +532,8 @@ int getenv_f(char *name, char *buf, unsigned len)
 		if (n)
 			*--buf = '\0';
 
-		printf("env_buf too small [%d]\n", len);
+		printf("env_buf [%d bytes] too small for value of \"%s\"\n",
+			len, name);
 
 		return n;
 	}
Signature · 1 line
1.7.4.4
author Applied
#1 lore raw

PATCH 1/1 cmd_nvedit.c: make error message more helpful

Dear Wolfgang Denk,

Quoted 10 lines · In message <[email protected]> you wrote:

When calling getenv_f() with a too small buffer, it would print an error message like this:

env_buf too small [32]

This is not really helpful as it does not give any indication which of the calls might have failed. Change this into:

env_buf [32 bytes] too small for value of "hwconfig"

Quoted 7 lines

so we know at least which variable caused the overflow; this usually allows to quickly find the related code as well.

---
 common/cmd_nvedit.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The X11 source code style is ATROCIOUS and should not be used  as  a
model."                                                   - Doug Gwyn