Skip to contentSkip to conversation

bootm: Handle errors consistently

PATCH Superseded Tom Rini 2 participants 3 messages Jul 10, 2013 – Jul 12, 2013

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH v3 1/1 bootm: Handle errors consistently

From: Simon Glass <[email protected]>

A recent bootm fix left the error path incomplete. If CONFIG_TRACE is set it may still not be a supported command, so cover that with the unsupported subcommand print. Once we handle BOOTM_STATE_OS_GO, we can just move into the error handler itself, no need for a goto there.

[trini: Update slightly based on Simon's changes to also cover CONFIG_TRACE/BOOTM_STATE_FAKE_OS_GO]

---
 common/cmd_bootm.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
common/cmd_bootm.c +8 -13
index a783cea..6caa0e9 100644
@@ -705,13 +705,6 @@ static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
 	if (!ret && (states & BOOTM_STATE_OS_PREP))
 		ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
 
-	/* Check for unsupported subcommand. */
-	if (ret) {
-		puts("subcommand not supported\n");
-		return ret;
-	}
-
-
 #ifdef CONFIG_TRACE
 	/* Pretend to run the OS, then run a user command */
 	if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
@@ -723,15 +716,17 @@ static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
 			ret = run_command_list(cmd_list, -1, flag);
 	}
 #endif
+
+	/* Check for unsupported subcommand. */
+	if (ret) {
+		puts("subcommand not supported\n");
+		return ret;
+	}
+
 	/* Now run the OS! We hope this doesn't return */
-	if (!ret && (states & BOOTM_STATE_OS_GO)) {
+	if (!ret && (states & BOOTM_STATE_OS_GO))
 		ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
 				images, boot_fn);
-		if (ret)
-			goto err;
-	}
-
-	return ret;
 
 	/* Deal with any fallout */
 err:
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/1 bootm: Handle errors consistently

Hi Tom,

Quoted 58 lines · Tom Rini

From: Simon Glass <[email protected]>

A recent bootm fix left the error path incomplete. If CONFIG_TRACE is set it may still not be a supported command, so cover that with the unsupported subcommand print. Once we handle BOOTM_STATE_OS_GO, we can just move into the error handler itself, no need for a goto there.

[trini: Update slightly based on Simon's changes to also cover CONFIG_TRACE/BOOTM_STATE_FAKE_OS_GO]

---
 common/cmd_bootm.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
common/cmd_bootm.c +0 -7
index a783cea..6caa0e9 100644
@@ -705,13 +705,6 @@ static int do_bootm_states(cmd_tbl_t *cmdtp, int
 flag, int argc,
        if (!ret && (states & BOOTM_STATE_OS_PREP))
                ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images);
 
-       /* Check for unsupported subcommand. */
-       if (ret) {
-               puts("subcommand not supported\n");
-               return ret;
-       }
-
-
 #ifdef CONFIG_TRACE
        /* Pretend to run the OS, then run a user command */
        if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
common/cmd_bootm.c +8 -6
@@ -723,15 +716,17 @@ static int do_bootm_states(cmd_tbl_t *cmdtp, int
 flag, int argc,
                        ret = run_command_list(cmd_list, -1, flag);
        }
 #endif
+
+       /* Check for unsupported subcommand. */
+       if (ret) {
+               puts("subcommand not supported\n");
+               return ret;
+       }
+
        /* Now run the OS! We hope this doesn't return */
-       if (!ret && (states & BOOTM_STATE_OS_GO)) {
+       if (!ret && (states & BOOTM_STATE_OS_GO))
                ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
                                images, boot_fn);
-               if (ret)
-                       goto err;
-       }
-
-       return ret;
 
        /* Deal with any fallout */
Quoted 5 lines

err:
--
1.7.9.5

Yes I missed your previous change which solved this problem. This patch looks good to me, thanks.

Regards,
Simon

author
#2 lore raw

PATCH v3 1/1 bootm: Handle errors consistently

In reply to Tom Rini
Quoted 11 lines · Tom Rini

From: Simon Glass <[email protected]>

A recent bootm fix left the error path incomplete. If CONFIG_TRACE is set it may still not be a supported command, so cover that with the unsupported subcommand print. Once we handle BOOTM_STATE_OS_GO, we can just move into the error handler itself, no need for a goto there.

[trini: Update slightly based on Simon's changes to also cover CONFIG_TRACE/BOOTM_STATE_FAKE_OS_GO]

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130712/2c668f05/attachment.pgp>