From 3723324042ec92739d802604558a3ebe3d5616dc Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 4 Jun 2018 13:29:49 +0200 Subject: common: command: Use command_ret_t enum values instead of values Use enum command_ret_t types in cmd_process_error(). Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- common/command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/command.c') diff --git a/common/command.c b/common/command.c index 52d47c133c3..a4a8dc601ac 100644 --- a/common/command.c +++ b/common/command.c @@ -549,8 +549,8 @@ int cmd_process_error(cmd_tbl_t *cmdtp, int err) { if (err) { printf("Command '%s' failed: Error %d\n", cmdtp->name, err); - return 1; + return CMD_RET_FAILURE; } - return 0; + return CMD_RET_SUCCESS; } -- cgit v1.2.3 From 27eb7bce3943111dd70c19569b60d9a047f06811 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 21 Jun 2018 14:49:26 +0200 Subject: common: command: Handle USAGE failure separately command_ret_t enum contains 3 return values but only two are handled now. Extend cmd_process_error() and handle CMD_RET_USAGE separately. These commands are affected by this change. cmd/demo.c cmd/efi.c cmd/gpio.c cmd/qfw.c cmd/x86/fsp.c test/dm/cmd_dm.c And scripts shouldn't be affected because return value is not 0. But every command implementation can choose what it is correct to pass. I would expect that RET_USAGE is called when parameters are not correctly passed (have incorrect value, missing parameters) and RET_FAILURE when correct parameters are passed but command fails. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- common/command.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common/command.c') diff --git a/common/command.c b/common/command.c index a4a8dc601ac..2433a89e0a8 100644 --- a/common/command.c +++ b/common/command.c @@ -547,6 +547,9 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], int cmd_process_error(cmd_tbl_t *cmdtp, int err) { + if (err == CMD_RET_USAGE) + return CMD_RET_USAGE; + if (err) { printf("Command '%s' failed: Error %d\n", cmdtp->name, err); return CMD_RET_FAILURE; -- cgit v1.2.3