public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Fix handling of some broken test expressions
@ 2012-11-15 14:36 Domenico Andreoli
  0 siblings, 0 replies; only message in thread
From: Domenico Andreoli @ 2012-11-15 14:36 UTC (permalink / raw)
  To: u-boot

Observed incorrect bahavior (some debug traces are enabled):

U-Boot# test = yes
test(3): '=' 'yes': returns 0
U-Boot# test yes =
test(3): 'yes' '=': returns 0

This means that any "if test" with such broken expressions (maybe due to
an empty variable) in incorrectly evaluated as true.

Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
---
 common/cmd_test.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/cmd_test.c b/common/cmd_test.c
index d4ec186..dedda30 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -64,7 +64,7 @@ static int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			adv = 3;
 
 		if (left < adv) {
-			expr = 1;
+			expr = 0;
 			break;
 		}
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-15 14:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15 14:36 [U-Boot] [PATCH] Fix handling of some broken test expressions Domenico Andreoli

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