Skip to contentSkip to conversation

CMD: random: fix return code

PATCH In review Eugeniy Paltsev 3 participants 4 messages Mar 20, 2020 – Apr 28, 2020 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CMD: random: fix return code

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.

---
 cmd/mem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
cmd/mem.c +4 -5
index 6d54f195272..6b4897dfd94 100644
@@ -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
 
Signature · 1 line
2.21.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Eugeniy Paltsev

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.

Quoted 8 lines

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

---
 cmd/mem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
author Reviewed-by Simon Glass
#2 lore raw

Hi Simon, Tom,

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

---
Eugeniy Paltsev

________________________________________
From: Simon Glass <[email protected]>
Sent: Monday, March 23, 2020 18:37
To: Eugeniy Paltsev
Cc: Tom Rini; U-Boot Mailing List; uboot-snps-arc at synopsys.com; Alexey Brodkin; linux-snps-arc at lists.infradead.org
Subject: Re: [PATCH] CMD: random: fix return code

Quoted 5 lines · Eugeniy Paltsev

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.

Quoted 8 lines

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

---
 cmd/mem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
#3 lore raw
In reply to Eugeniy Paltsev
Quoted 9 lines · Eugeniy Paltsev

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.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200428/8548ecae/attachment.sig>