[RFC PATCH 2/4] startup: wrap barebox startup in TRY/CATCH

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Install a top level exception handler around barebox_main, so we may
catch THROWs that aren't contained in a TRY { } block.

Reviewed-by: Ahmad Fatoum <ahmad@xxxxxx>
---
 common/startup.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index c417a4d0781a..41da1359def6 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -348,27 +348,35 @@ void __noreturn start_barebox(void)
 	if (!IS_ENABLED(CONFIG_SHELL_NONE) && IS_ENABLED(CONFIG_COMMAND_SUPPORT))
 		barebox_main = run_init;
 
-	for (initcall = __barebox_initcalls_start;
-			initcall < __barebox_initcalls_end; initcall++) {
-		pr_debug("initcall-> %pS\n", *initcall);
-		result = (*initcall)();
-		if (result)
-			pr_err("initcall %pS failed: %s\n", *initcall,
-					strerror(-result));
-	}
+	TRY {
+		for (initcall = __barebox_initcalls_start;
+				initcall < __barebox_initcalls_end; initcall++) {
+			pr_debug("initcall-> %pS\n", *initcall);
+			result = (*initcall)();
+			if (result)
+				pr_err("initcall %pS failed: %s\n", *initcall,
+						strerror(-result));
+		}
 
-	pr_debug("initcalls done\n");
+		pr_debug("initcalls done\n");
 
-	if (barebox_main)
-		barebox_main();
+		if (barebox_main)
+			barebox_main();
 
-	if (IS_ENABLED(CONFIG_SHELL_NONE)) {
-		pr_err("Nothing left to do\n");
-		hang();
-	} else {
-		while (1)
-			run_shell();
+		if (IS_ENABLED(CONFIG_SHELL_NONE)) {
+			pr_err("Nothing left to do\n");
+			hang();
+		} else {
+			while (1)
+				run_shell();
+		}
+	} CATCH_ALL {
+		panic("Unhandled exception");
 	}
+
+
+	ENDTRY;
+
 }
 
 void __noreturn hang (void)
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux