Patchwork [U-Boot] Fix handling of some broken test expressions

login
register
mail settings
Submitter Domenico Andreoli
Date Nov. 15, 2012, 2:36 p.m.
Message ID <20121115143609.GA3957@glitch>
Download mbox | patch
Permalink /patch/199371/
State New
Delegated to: Tom Rini
Headers show

Comments

Domenico Andreoli - Nov. 15, 2012, 2:36 p.m.
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(-)

Patch

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;
 		}