diff mbox series

CMD: random: fix return code

Message ID 20200320163817.8628-1-Eugeniy.Paltsev@synopsys.com
State Accepted
Commit 5f2c4e0129bf644dbde3c75119406eceaded2aa2
Delegated to: Tom Rini
Headers show
Series CMD: random: fix return code | expand

Commit Message

Eugeniy Paltsev March 20, 2020, 4:38 p.m. UTC
As of today 'random' command return 1 (CMD_RET_FAILURE) in case
of successful execution and 0 (CMD_RET_SUCCESS) in case of bad
arguments. Fix that.

NOTE: we remove printing usage information from command body
so it won't print twice.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
 cmd/mem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Simon Glass March 23, 2020, 3:37 p.m. UTC | #1
On Fri, 20 Mar 2020 at 10:38, Eugeniy Paltsev
<Eugeniy.Paltsev@synopsys.com> wrote:
>
> As of today 'random' command return 1 (CMD_RET_FAILURE) in case
> of successful execution and 0 (CMD_RET_SUCCESS) in case of bad
> arguments. Fix that.
>
> NOTE: we remove printing usage information from command body
> so it won't print twice.
>
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> ---
>  cmd/mem.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Eugeniy Paltsev April 24, 2020, 9:20 p.m. UTC | #2
Hi Simon, Tom,

I guess it's perfect time to apply this patch. Thanks!

---
 Eugeniy Paltsev
Tom Rini April 28, 2020, 1:53 p.m. UTC | #3
On Fri, Mar 20, 2020 at 07:38:17PM +0300, Eugeniy Paltsev wrote:

> As of today 'random' command return 1 (CMD_RET_FAILURE) in case
> of successful execution and 0 (CMD_RET_SUCCESS) in case of bad
> arguments. Fix that.
> 
> NOTE: we remove printing usage information from command body
> so it won't print twice.
> 
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/cmd/mem.c b/cmd/mem.c
index 6d54f195272..6b4897dfd94 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -1102,10 +1102,8 @@  static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	unsigned char *buf8;
 	unsigned int i;
 
-	if (argc < 3 || argc > 4) {
-		printf("usage: %s <addr> <len> [<seed>]\n", argv[0]);
-		return 0;
-	}
+	if (argc < 3 || argc > 4)
+		return CMD_RET_USAGE;
 
 	len = simple_strtoul(argv[2], NULL, 16);
 	addr = simple_strtoul(argv[1], NULL, 16);
@@ -1132,7 +1130,8 @@  static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	unmap_sysmem(start);
 	printf("%lu bytes filled with random data\n", len);
-	return 1;
+
+	return CMD_RET_SUCCESS;
 }
 #endif