From 47e26b1bf91ddef69f4a3892815c857db094cef9 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Sat, 17 Jul 2010 01:06:04 +0200 Subject: cmd_usage(): simplify return code handling Lots of code use this construct: cmd_usage(cmdtp); return 1; Change cmd_usage() let it return 1 - then we can replace all these ocurrances by return cmd_usage(cmdtp); This fixes a few places with incorrect return code handling, too. Signed-off-by: Wolfgang Denk --- common/cmd_mem.c | 80 +++++++++++++++++++------------------------------------- 1 file changed, 27 insertions(+), 53 deletions(-) (limited to 'common/cmd_mem.c') diff --git a/common/cmd_mem.c b/common/cmd_mem.c index bcea3992db..44834ea751 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -76,10 +76,8 @@ int do_mem_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) size = dp_last_size; length = dp_last_length; - if (argc < 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 2) + return cmd_usage(cmdtp); if ((flag & CMD_FLAG_REPEAT) == 0) { /* New command specified. Check for a size specification. @@ -172,10 +170,8 @@ int do_mem_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong addr, writeval, count; int size; - if ((argc < 3) || (argc > 4)) { - cmd_usage(cmdtp); - return 1; - } + if ((argc < 3) || (argc > 4)) + return cmd_usage(cmdtp); /* Check for size specification. */ @@ -216,10 +212,8 @@ int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int i; ulong count; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); count = simple_strtoul(argv[3], NULL, 10); @@ -245,10 +239,8 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int i; ulong count; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); count = simple_strtoul(argv[3], NULL, 10); @@ -276,10 +268,8 @@ int do_mem_cmp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int size; int rcode = 0; - if (argc != 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 4) + return cmd_usage(cmdtp); /* Check for size specification. */ @@ -360,10 +350,8 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong addr, dest, count; int size; - if (argc != 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 4) + return cmd_usage(cmdtp); /* Check for size specification. */ @@ -484,10 +472,8 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) volatile ushort *shortp; volatile u_char *cp; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); /* Check for a size spefication. * Defaults to long if no or incorrect specification. @@ -555,10 +541,8 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) volatile ushort *shortp; volatile u_char *cp; - if (argc < 4) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 4) + return cmd_usage(cmdtp); /* Check for a size spefication. * Defaults to long if no or incorrect specification. @@ -990,10 +974,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) int nbytes, size; extern char console_buffer[]; - if (argc != 2) { - cmd_usage(cmdtp); - return 1; - } + if (argc != 2) + return cmd_usage(cmdtp); #ifdef CONFIG_BOOT_RETRY_TIME reset_cmd_timeout(); /* got a good command to get here */ @@ -1095,10 +1077,8 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong crc; ulong *ptr; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul (argv[1], NULL, 16); addr += base_address; @@ -1131,9 +1111,8 @@ int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char * const *av; if (argc < 3) { - usage: - cmd_usage(cmdtp); - return 1; +usage: + return cmd_usage(cmdtp); } av = argv + 1; @@ -1181,10 +1160,8 @@ int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned int i; u8 output[16]; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul(argv[1], NULL, 16); len = simple_strtoul(argv[2], NULL, 16); @@ -1206,10 +1183,8 @@ int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned int i; u8 output[20]; - if (argc < 3) { - cmd_usage(cmdtp); - return 1; - } + if (argc < 3) + return cmd_usage(cmdtp); addr = simple_strtoul(argv[1], NULL, 16); len = simple_strtoul(argv[2], NULL, 16); @@ -1239,8 +1214,7 @@ int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) dst = simple_strtoul(argv[2], NULL, 16); break; default: - cmd_usage(cmdtp); - return 1; + return cmd_usage(cmdtp); } return !!gunzip((void *) dst, dst_len, (void *) src, &src_len); -- cgit