summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/assert.h6
-rw-r--r--core/cortex-m/panic.c1
-rw-r--r--core/cortex-m0/panic.c1
-rw-r--r--core/nds32/panic.c1
-rw-r--r--include/panic.h7
5 files changed, 11 insertions, 5 deletions
diff --git a/builtin/assert.h b/builtin/assert.h
index 2db11115a7..1a4c64eb68 100644
--- a/builtin/assert.h
+++ b/builtin/assert.h
@@ -15,14 +15,15 @@
#ifdef CONFIG_DEBUG_ASSERT_REBOOTS
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
-extern void panic_assert_fail(const char *fname, int linenum);
+extern void panic_assert_fail(const char *fname, int linenum)
+ __attribute__((noreturn));
#define ASSERT(cond) do { \
if (!(cond)) \
panic_assert_fail(__FILE__, __LINE__); \
} while (0)
#else
extern void panic_assert_fail(const char *msg, const char *func,
- const char *fname, int linenum);
+ const char *fname, int linenum) __attribute__((noreturn));
#define ASSERT(cond) do { \
if (!(cond)) \
panic_assert_fail(#cond, __func__, __FILE__, \
@@ -33,6 +34,7 @@ extern void panic_assert_fail(const char *msg, const char *func,
#define ASSERT(cond) do { \
if (!(cond)) \
__asm("bkpt"); \
+ __builtin_unreachable();\
} while (0)
#endif
#else
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c
index 703586c135..bc049bd698 100644
--- a/core/cortex-m/panic.c
+++ b/core/cortex-m/panic.c
@@ -383,6 +383,7 @@ void software_panic(uint32_t reason, uint32_t info)
"mov " STRINGIFY(SOFTWARE_PANIC_REASON_REG) ", %1\n"
"bl exception_panic\n"
: : "r"(info), "r"(reason));
+ __builtin_unreachable();
}
void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
diff --git a/core/cortex-m0/panic.c b/core/cortex-m0/panic.c
index 9cbc00107a..02adb63164 100644
--- a/core/cortex-m0/panic.c
+++ b/core/cortex-m0/panic.c
@@ -172,6 +172,7 @@ void software_panic(uint32_t reason, uint32_t info)
"mov " STRINGIFY(SOFTWARE_PANIC_REASON_REG) ", %1\n"
"bl exception_panic\n"
: : "r"(info), "r"(reason));
+ __builtin_unreachable();
}
void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
diff --git a/core/nds32/panic.c b/core/nds32/panic.c
index cd73a6f3c3..4c855b5c06 100644
--- a/core/nds32/panic.c
+++ b/core/nds32/panic.c
@@ -98,6 +98,7 @@ void software_panic(uint32_t reason, uint32_t info)
asm("j excep_handler");
else
asm("break 0");
+ __builtin_unreachable();
}
void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
diff --git a/include/panic.h b/include/panic.h
index e5e16dd190..8a689c4b23 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -118,10 +118,11 @@ void panic_data_print(const struct panic_data *pdata);
* @param linenum Line number where assertion happened
*/
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
-void panic_assert_fail(const char *fname, int linenum);
+void panic_assert_fail(const char *fname, int linenum)
+ __attribute__((noreturn));
#else
void panic_assert_fail(const char *msg, const char *func, const char *fname,
- int linenum);
+ int linenum) __attribute__((noreturn));
#endif
/**
@@ -141,7 +142,7 @@ void panic_reboot(void) __attribute__((noreturn));
* Store a panic log and halt the system for a software-related reason, such as
* stack overflow or assertion failure.
*/
-void software_panic(uint32_t reason, uint32_t info);
+void software_panic(uint32_t reason, uint32_t info) __attribute__((noreturn));
/**
* Log a panic in the panic log, but don't halt the system. Normally