[PATCH 7/8] common/parser.c: Do not conflate error reporting disciplines

Andrey Smirnov andrew.smirnov at gmail.com
Sun Oct 11 11:43:40 PDT 2015


Run_command() uses 0 to indicate success and negative values to
indicate errors, whereas execute_command() uses 0 for success and
positive integers to represent error codes. Conflating the two breaks
the code that calls run_command and then checks for error code sign to
detect problems, so avoid that by doing a very simple transformation
on the result of execute_command

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 common/parser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/parser.c b/common/parser.c
index ed414d0..2b95aed 100644
--- a/common/parser.c
+++ b/common/parser.c
@@ -253,7 +253,8 @@ int run_command(const char *cmd)
 			continue;
 		}
 
-		rc = execute_command(argc, argv);
+		if (execute_command(argc, argv) != COMMAND_SUCCESS)
+			rc = -1;
 	}
 
 	return rc;
-- 
2.1.4




More information about the barebox mailing list