Skip to content

Commit 3e02536

Browse files
etienne-lmsnordicjm
authored andcommitted
boot: bootutil: declare fih_panic_loop() as noreturn
Add noreturn attribute the fih_panic_loop() and add a terminal endless loop in the function to prevent build warnings like the below one found when build MCUBOOT in TF-M: .../arm-none-eabi/include/assert.h: In function '__assert_func': .../trusted-firmware-m/platform/ext/common/tfm_assert.c:22:1: warning: 'noreturn' function does return 22 | } | ^ Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
1 parent 5eaf190 commit 3e02536

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

boot/bootutil/include/bootutil/fault_injection_hardening.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ extern fih_ret FIH_BOOT_HOOK_REGULAR;
137137
/* Global failure handler - more resistant to unlooping. noinline and used are
138138
* used to prevent optimization
139139
*/
140-
__attribute__((noinline)) __attribute__((used))
140+
__attribute__((noinline)) __attribute__((used)) __attribute__((noreturn))
141141
void fih_panic_loop(void);
142142
#define FIH_PANIC fih_panic_loop()
143143
#else

boot/bootutil/src/fault_injection_hardening.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void fih_cfi_decrement(void)
6363
*/
6464
__attribute__((used))
6565
__attribute__((noinline))
66+
__attribute__((noreturn))
6667
void fih_panic_loop(void)
6768
{
6869
__asm volatile ("b fih_panic_loop");
@@ -74,5 +75,10 @@ void fih_panic_loop(void)
7475
__asm volatile ("b fih_panic_loop");
7576
__asm volatile ("b fih_panic_loop");
7677
__asm volatile ("b fih_panic_loop");
78+
79+
/* An infinite loop to suppress compiler warnings
80+
* about the return of a noreturn function
81+
*/
82+
while (1) {}
7783
}
7884
#endif /* FIH_ENABLE_GLOBAL_FAIL */

0 commit comments

Comments
 (0)