assert/panic: mark noreturn to inform the compiler

BUG=b:65441143
BRANCH=none
TEST=buildall with gcc8.1 stops failing on this family of functions

Change-Id: I44f9d643e46f955ea0cd0b5893c2806a4e3f52b0
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1126315
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
This commit is contained in:
Patrick Georgi 2018-07-04 17:21:09 +02:00 committed by chrome-bot
parent 97a7b12b3b
commit 7e972ab986
5 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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