Skip to contentSkip to conversation

do_smhload: fix return code

PATCH In review Ryan Harkin 3 participants 3 messages Mar 2, 2017 – Mar 10, 2017 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do_smhload: fix return code

do_smhload was using a ulong to store the return value from smh_load_file. That returns an int, where -1 indicates an error. As a ulong will never be negative, smh_load_file errors were not detected and so_smhload always returned zero.

Also, when errors were spotted, do_smhload was returning 1, rather than the enumeration CMD_RET_FAILURE (which is also 1).

---
 arch/arm/lib/semihosting.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/semihosting.c +2 -2
index e32ad90..415ac89 100644
@@ -186,7 +186,7 @@ static int do_smhload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc == 3 || argc == 4) {
 		ulong load_addr;
 		ulong end_addr = 0;
-		ulong ret;
+		int ret;
 		char end_str[64];
 
 		load_addr = simple_strtoul(argv[2], NULL, 16);
@@ -195,7 +195,7 @@ static int do_smhload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		ret = smh_load_file(argv[1], load_addr, &end_addr);
 		if (ret < 0)
-			return 1;
+			return CMD_RET_FAILURE;
 
 		/* Optionally save returned end to the environment */
 		if (argc == 4) {
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 do_smhload: fix return code

Quoted 9 lines · Ryan Harkin

do_smhload was using a ulong to store the return value from smh_load_file. That returns an int, where -1 indicates an error. As a ulong will never be negative, smh_load_file errors were not detected and so_smhload always returned zero.

Also, when errors were spotted, do_smhload was returning 1, rather than the enumeration CMD_RET_FAILURE (which is also 1).

Yours,
Linus Walleij

#2 lore raw
In reply to Ryan Harkin
Quoted 10 lines · Ryan Harkin

do_smhload was using a ulong to store the return value from smh_load_file. That returns an int, where -1 indicates an error. As a ulong will never be negative, smh_load_file errors were not detected and so_smhload always returned zero.

Also, when errors were spotted, do_smhload was returning 1, rather than the enumeration CMD_RET_FAILURE (which is also 1).

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: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170310/1047c941/attachment.sig>