fix(esp_system): fix GCC 14 analyzer warnings

This commit is contained in:
Alexey Lapshin 2024-07-04 23:57:11 +07:00
parent 4c87af6359
commit 7498f4655a
16 changed files with 58 additions and 48 deletions

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -11,6 +11,7 @@ This header contains various general purpose helper macros used across ESP-IDF
*/ */
#include <assert.h> #include <assert.h>
#include "esp_assert.h" #include "esp_assert.h"
#include "esp_compiler.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -51,7 +52,7 @@ extern "C" {
* - __GET_NTH_ARG__() takes args >= N (64) but only expand to Nth one (64th) * - __GET_NTH_ARG__() takes args >= N (64) but only expand to Nth one (64th)
* - __RSEQ_N__() is reverse sequential to N to add padding to have Nth * - __RSEQ_N__() is reverse sequential to N to add padding to have Nth
* position is the same as the number of arguments * position is the same as the number of arguments
* - ##__VA_ARGS__ is used to deal with 0 paramerter (swallows comma) * - ##__VA_ARGS__ is used to deal with 0 parameter (swallows comma)
*/ */
#ifndef __VA_NARG__ #ifndef __VA_NARG__
# define __VA_NARG__(...) __NARG__(_0, ##__VA_ARGS__, __RSEQ_N__()) # define __VA_NARG__(...) __NARG__(_0, ##__VA_ARGS__, __RSEQ_N__())
@ -98,6 +99,13 @@ ESP_STATIC_ASSERT(foo(42, 87) == 1, "CHOOSE_MACRO_VA_ARG() result does not match
#undef foo_args #undef foo_args
#undef foo_no_args #undef foo_no_args
#define ESP_INFINITE_LOOP() \
do { \
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-infinite-loop") \
while(1); \
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-infinite-loop") \
} while(1)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "esp_macros.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_attr.h" #include "esp_attr.h"
#include "esp_compiler.h" #include "esp_compiler.h"
@ -442,7 +443,7 @@ void esp_panic_handler(panic_info_t *info)
disable_all_wdts(); disable_all_wdts();
panic_print_str("CPU halted.\r\n"); panic_print_str("CPU halted.\r\n");
esp_system_reset_modules_on_exit(); esp_system_reset_modules_on_exit();
while (1); ESP_INFINITE_LOOP();
#endif /* CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT */ #endif /* CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT */
#endif /* CONFIG_ESP_SYSTEM_PANIC_GDBSTUB */ #endif /* CONFIG_ESP_SYSTEM_PANIC_GDBSTUB */
} }
@ -467,7 +468,7 @@ void IRAM_ATTR __attribute__((noreturn, no_sanitize_undefined)) panic_abort(cons
asm("unimp"); // should be an invalid operation on RISC-V targets asm("unimp"); // should be an invalid operation on RISC-V targets
#endif #endif
while (1); ESP_INFINITE_LOOP();
} }
/* Weak versions of reset reason hint functions. /* Weak versions of reset reason hint functions.

View File

@ -65,7 +65,7 @@ esp_err_t IRAM_ATTR esp_backtrace_print_from_frame(int depth, const esp_backtrac
} }
//Initialize stk_frame with first frame of stack //Initialize stk_frame with first frame of stack
esp_backtrace_frame_t stk_frame = { 0 }; esp_backtrace_frame_t stk_frame;
memcpy(&stk_frame, frame, sizeof(esp_backtrace_frame_t)); memcpy(&stk_frame, frame, sizeof(esp_backtrace_frame_t));
print_str("\r\n\r\nBacktrace:", panic); print_str("\r\n\r\nBacktrace:", panic);
@ -197,7 +197,7 @@ esp_err_t IRAM_ATTR esp_backtrace_print_all_tasks(int depth)
for (UBaseType_t task_idx = 0; task_idx < num_snapshots; task_idx++) { for (UBaseType_t task_idx = 0; task_idx < num_snapshots; task_idx++) {
bool cur_running = false; bool cur_running = false;
TaskHandle_t task_hdl = (TaskHandle_t) task_snapshots[task_idx].pxTCB; TaskHandle_t task_hdl = (TaskHandle_t) task_snapshots[task_idx].pxTCB;
esp_backtrace_frame_t stk_frame; esp_backtrace_frame_t stk_frame = {0};
// Check if the task is one of the currently running tasks // Check if the task is one of the currently running tasks
for (BaseType_t core_id = 0; core_id < configNUMBER_OF_CORES; core_id++) { for (BaseType_t core_id = 0; core_id < configNUMBER_OF_CORES; core_id++) {

View File

@ -11,6 +11,7 @@
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_private/rtc_ctrl.h" #include "esp_private/rtc_ctrl.h"
#include "esp_private/spi_flash_os.h" #include "esp_private/spi_flash_os.h"
#include "esp_macros.h"
#include "esp_log.h" #include "esp_log.h"
#include "esp_cpu.h" #include "esp_cpu.h"
#include "soc/soc.h" #include "soc/soc.h"
@ -67,9 +68,8 @@ IRAM_ATTR static void rtc_brownout_isr_handler(void *arg)
} }
esp_rom_software_reset_system(); esp_rom_software_reset_system();
while (true) {
; ESP_INFINITE_LOOP();
}
} }
#endif // CONFIG_ESP_SYSTEM_BROWNOUT_INTR #endif // CONFIG_ESP_SYSTEM_BROWNOUT_INTR

View File

@ -5,6 +5,7 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include "esp_macros.h"
#include "esp_cpu.h" #include "esp_cpu.h"
#include "soc/soc.h" #include "soc/soc.h"
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
@ -61,9 +62,8 @@ void IRAM_ATTR esp_restart_noos_dig(void)
#endif #endif
// generate core reset // generate core reset
esp_rom_software_reset_system(); esp_rom_software_reset_system();
while (true) {
; ESP_INFINITE_LOOP();
}
} }
#endif #endif

View File

@ -6,6 +6,8 @@
#include <stdlib.h> #include <stdlib.h>
#include "esp_macros.h"
#include "esp_ipc_isr.h" #include "esp_ipc_isr.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_private/cache_utils.h" #include "esp_private/cache_utils.h"
@ -124,7 +126,7 @@ static void frame_to_panic_info(void *frame, panic_info_t *info, bool pseudo_exc
FORCE_INLINE_ATTR __attribute__((__noreturn__)) FORCE_INLINE_ATTR __attribute__((__noreturn__))
void busy_wait(void) void busy_wait(void)
{ {
while (1) {;} // infinite loop ESP_INFINITE_LOOP();
} }
#endif // !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE #endif // !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE

View File

@ -1,10 +1,11 @@
/* /*
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -140,7 +141,6 @@ void IRAM_ATTR esp_restart_noos(void)
esp_cpu_unstall(0); esp_cpu_unstall(0);
esp_rom_software_reset_cpu(1); esp_rom_software_reset_cpu(1);
} }
while (true) {
; ESP_INFINITE_LOOP();
}
} }

View File

@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -95,7 +96,5 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset CPU // Reset CPU
esp_rom_software_reset_cpu(0); esp_rom_software_reset_cpu(0);
while (true) { ESP_INFINITE_LOOP();
;
}
} }

View File

@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -107,7 +108,6 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset CPU // Reset CPU
esp_rom_software_reset_cpu(0); esp_rom_software_reset_cpu(0);
while (true) {
; ESP_INFINITE_LOOP();
}
} }

View File

@ -6,6 +6,7 @@
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -113,7 +114,6 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset PRO CPU // Reset PRO CPU
esp_rom_software_reset_cpu(0); esp_rom_software_reset_cpu(0);
while (true) {
; ESP_INFINITE_LOOP();
}
} }

View File

@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -112,7 +113,6 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset PRO CPU // Reset PRO CPU
esp_rom_software_reset_cpu(0); esp_rom_software_reset_cpu(0);
while (true) {
; ESP_INFINITE_LOOP();
}
} }

View File

@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -114,7 +115,5 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset CPU // Reset CPU
esp_rom_software_reset_cpu(0); esp_rom_software_reset_cpu(0);
while (true) { ESP_INFINITE_LOOP();
;
}
} }

View File

@ -6,6 +6,7 @@
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -164,7 +165,5 @@ void IRAM_ATTR esp_restart_noos(void)
} }
#endif #endif
while (true) { ESP_INFINITE_LOOP();
;
}
} }

View File

@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -114,7 +115,6 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset CPUs // Reset CPUs
esp_rom_software_reset_cpu(0); esp_rom_software_reset_cpu(0);
while (true) {
; ESP_INFINITE_LOOP();
}
} }

View File

@ -1,11 +1,12 @@
/* /*
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <string.h> #include <string.h>
#include "esp_macros.h"
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
@ -155,7 +156,6 @@ void IRAM_ATTR esp_restart_noos(void)
esp_rom_software_reset_cpu(1); esp_rom_software_reset_cpu(1);
} }
#endif #endif
while (true) {
; ESP_INFINITE_LOOP();
}
} }

View File

@ -10,6 +10,7 @@
#include "esp_attr.h" #include "esp_attr.h"
#include "esp_err.h" #include "esp_err.h"
#include "esp_compiler.h" #include "esp_compiler.h"
#include "esp_macros.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_log.h" #include "esp_log.h"
@ -213,5 +214,6 @@ static void start_cpu0_default(void)
#endif #endif
esp_startup_start_app(); esp_startup_start_app();
while (1);
ESP_INFINITE_LOOP();
} }