From 04d8c2541d427a04875b7ae4a5862ea567f56df0 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sun, 11 Oct 2015 11:43:41 -0700 Subject: common/parser.c: Do not treat zero return code as error Run_command() would return zero to indicated success so treating it as error case would completely break command repetition logic, so change comparinson operator from "less or equal" to "less then" Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- common/parser.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'common/parser.c') diff --git a/common/parser.c b/common/parser.c index 2b95aeda16..6136dbf36f 100644 --- a/common/parser.c +++ b/common/parser.c @@ -266,7 +266,6 @@ int run_shell(void) { static char lastcommand[CONFIG_CBSIZE] = { 0, }; int len; - int rc = 1; login(); @@ -276,14 +275,14 @@ int run_shell(void) if (len > 0) strcpy (lastcommand, console_buffer); - if (len == -1) + if (len == -1) { puts ("\n"); - else - rc = run_command(lastcommand); - - if (rc <= 0) { - /* invalid command or not repeatable, forget it */ - lastcommand[0] = 0; + } else { + const int rc = run_command(lastcommand); + if (rc < 0) { + /* invalid command or not repeatable, forget it */ + lastcommand[0] = 0; + } } } return 0; -- cgit v1.2.3