[U-Boot] [PATCH 5/6] hush: make run_command() return an error on parsing failure

Rabin Vincent rabin at rab.in
Wed Oct 29 23:21:41 CET 2014


run_command() returns success even if the command had a syntax error;
correct this behaviour.

Signed-off-by: Rabin Vincent <rabin at rab.in>
---
 common/cli_hush.c | 2 +-
 test/command_ut.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/cli_hush.c b/common/cli_hush.c
index a07ae71..d643912 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -3162,7 +3162,7 @@ static int parse_stream_outer(struct in_str *inp, int flag)
 	o_string temp=NULL_O_STRING;
 	int rcode;
 #ifdef __U_BOOT__
-	int code = 0;
+	int code = 1;
 #endif
 	do {
 		ctx.type = flag;
diff --git a/test/command_ut.c b/test/command_ut.c
index a4f0341..926573a 100644
--- a/test/command_ut.c
+++ b/test/command_ut.c
@@ -191,6 +191,8 @@ static int do_ut_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	assert(run_command("", 0) == 0);
 	assert(run_command(" ", 0) == 0);
 
+	assert(run_command("'", 0) == 1);
+
 	printf("%s: Everything went swimmingly\n", __func__);
 	return 0;
 }
-- 
2.1.1



More information about the U-Boot mailing list