[U-Boot] [PATCH] cmd_usage: Use ignored return value

Thomas Weber weber at corscience.de
Wed Nov 24 13:38:14 CET 2010


cmd_usage returns 1, so its return value can be used as return value.

Some functions ignore the return value of cmd_usage and return a "1" in
the next line. This patch changes these calls so that the return value of
cmd_usage is used as return value.

Signed-off-by: Thomas Weber <weber at corscience.de>
---
 arch/powerpc/cpu/ppc4xx/cmd_ecctest.c |    6 ++----
 board/gdsys/common/osd.c              |    6 ++----
 common/cmd_nvedit.c                   |   18 ++++++------------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/cpu/ppc4xx/cmd_ecctest.c b/arch/powerpc/cpu/ppc4xx/cmd_ecctest.c
index fd81b70..542ab69 100644
--- a/arch/powerpc/cpu/ppc4xx/cmd_ecctest.c
+++ b/arch/powerpc/cpu/ppc4xx/cmd_ecctest.c
@@ -190,15 +190,13 @@ static int do_ecctest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	int error;
 
 	if (argc < 3) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 
 	ptr = (u32 *)simple_strtoul(argv[1], NULL, 16);
 	error = simple_strtoul(argv[2], NULL, 16);
 	if ((error < 1) || (error > 2)) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 
 	printf("Using address %p for %d bit ECC error injection\n",
diff --git a/board/gdsys/common/osd.c b/board/gdsys/common/osd.c
index 05800ff..239c870 100644
--- a/board/gdsys/common/osd.c
+++ b/board/gdsys/common/osd.c
@@ -142,8 +142,7 @@ static int osd_print(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	char *text;
 
 	if (argc < 5) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 
 	x = simple_strtoul(argv[1], NULL, 16);
@@ -204,8 +203,7 @@ int osd_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	unsigned count = (argc > 4) ?  simple_strtoul(argv[4], NULL, 16) : 1;
 
 	if ((argc < 4) || (strlen(argv[3]) % 4)) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 
 	x = simple_strtoul(argv[1], NULL, 16);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 3fd8abc..cd19cc6 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -545,8 +545,7 @@ int envmatch (uchar *s1, int i2)
 static int do_env_default(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	if ((argc != 2) || (strcmp(argv[1], "-f") != 0)) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 	set_default_env("## Resetting to default environment\n");
 	return 0;
@@ -633,15 +632,13 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 				sep = '\n';
 				break;
 			default:
-				cmd_usage(cmdtp);
-				return 1;
+				return cmd_usage(cmdtp);
 			}
 		}
 	}
 
 	if (argc < 1) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 
 	addr = (char *)simple_strtoul(argv[0], NULL, 16);
@@ -744,15 +741,13 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
 				del = 1;
 				break;
 			default:
-				cmd_usage(cmdtp);
-				return 1;
+				return cmd_usage(cmdtp);
 			}
 		}
 	}
 
 	if (argc < 1) {
-		cmd_usage(cmdtp);
-		return 1;
+		return cmd_usage(cmdtp);
 	}
 
 	if (!fmt)
@@ -857,8 +852,7 @@ static int do_env (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (cp)
 		return cp->cmd(cmdtp, flag, argc, argv);
 
-	cmd_usage(cmdtp);
-	return 1;
+	return cmd_usage(cmdtp);
 }
 
 U_BOOT_CMD(
-- 
1.7.3.2



More information about the U-Boot mailing list