From b5606f5e81ba9f351d26667d4d26c86af8623d72 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 10 Sep 2021 19:29:05 +0200 Subject: [PATCH] esp_system: make the abort operation compatible with clang Clang warns that the original code wouldn't have any effect: warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference] note: consider using __builtin_trap() or qualifying pointer with 'volatile' __builtin_trap translates to 'break 1, 15' instruction on Xtensa, which might be okay in this case. However to absolutely certainly not break anything for GCC builds, add 'volatile' instead. --- components/esp_system/panic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index f673307dca..722975b7c7 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -399,7 +399,7 @@ void IRAM_ATTR __attribute__((noreturn, no_sanitize_undefined)) panic_abort(cons #endif #endif - *((int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets + *((volatile int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets while (1); }