summaryrefslogtreecommitdiff
path: root/common/panic_output.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-09 13:20:48 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-10 05:49:43 +0000
commitb1a173ea45a94368325440dd014417554c88918a (patch)
tree5222a0459bbc24856b77135ec911042ecddf621d /common/panic_output.c
parent039c889e1435da921d2e18dc63ab96e4cf437a07 (diff)
downloadchrome-ec-b1a173ea45a94368325440dd014417554c88918a.tar.gz
panic: Tidy up the #ifdefs
Move the common code into a separate function. Add comments to the nesting. Use IS_ENABLED() where possible and drop the outer #ifdef around the C code, since the linker will throw it away automatically if it is not called. BUG=b:177604307 BRANCH=none TEST=verified no code-size change on volteer Change-Id: I61065d37fb6267097a2078493a4edfcdeea23819 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686248 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/panic_output.c')
-rw-r--r--common/panic_output.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/common/panic_output.c b/common/panic_output.c
index 66a39a60cc..cbec6c2f00 100644
--- a/common/panic_output.c
+++ b/common/panic_output.c
@@ -126,16 +126,20 @@ void panic_reboot(void)
system_reset(0);
}
-#ifdef CONFIG_DEBUG_ASSERT_REBOOTS
+/* Complete the processing of a panic, after the initial message is shown */
+static noreturn void complete_panic(int linenum)
+{
+ if (IS_ENABLED(CONFIG_SOFTWARE_PANIC))
+ software_panic(PANIC_SW_ASSERT, linenum);
+ else
+ panic_reboot();
+}
+
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
void panic_assert_fail(const char *fname, int linenum)
{
panic_printf("\nASSERTION FAILURE at %s:%d\n", fname, linenum);
-#ifdef CONFIG_SOFTWARE_PANIC
- software_panic(PANIC_SW_ASSERT, linenum);
-#else
- panic_reboot();
-#endif
+ complete_panic(linenum);
}
#else
void panic_assert_fail(const char *msg, const char *func, const char *fname,
@@ -143,14 +147,9 @@ void panic_assert_fail(const char *msg, const char *func, const char *fname,
{
panic_printf("\nASSERTION FAILURE '%s' in %s() at %s:%d\n",
msg, func, fname, linenum);
-#ifdef CONFIG_SOFTWARE_PANIC
- software_panic(PANIC_SW_ASSERT, linenum);
-#else
- panic_reboot();
-#endif
+ complete_panic(linenum);
}
#endif
-#endif
void panic(const char *msg)
{