[esp32] Fix clang-tidy on ESP-IDF 6 (#16850)

This commit is contained in:
Jonathan Swoboda
2026-06-06 20:00:42 -04:00
committed by GitHub
parent 8400bab926
commit 64fc09646c
6 changed files with 17 additions and 8 deletions

View File

@@ -1 +1 @@
d9c755e5f019b2ecb324834717bc1fb8563e622f5751794cb7156d324884481e 58a760f5fd174bd438bcc3a7018292c158530c1a1d15181941c832d4c032511c

View File

@@ -222,6 +222,7 @@ bool BTHomeMiThermometer::decrypt_bthome_payload_(const std::vector<uint8_t> &da
} }
size_t plaintext_length; size_t plaintext_length;
// NOLINTNEXTLINE(readability-suspicious-call-argument) - similarly named size args are not swapped
psa_status_t status = psa_aead_decrypt(key_id, PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, BTHOME_MIC_SIZE), psa_status_t status = psa_aead_decrypt(key_id, PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, BTHOME_MIC_SIZE),
nonce.data(), nonce.size(), nullptr, 0, ct_with_tag, ct_with_tag_size, nonce.data(), nonce.size(), nullptr, 0, ct_with_tag, ct_with_tag_size,
payload.data(), ciphertext_size, &plaintext_length); payload.data(), ciphertext_size, &plaintext_length);

View File

@@ -165,6 +165,8 @@ void LEDCOutput::write_state(float state) {
void LEDCOutput::setup() { void LEDCOutput::setup() {
if (!ledc_peripheral_reset_done) { if (!ledc_peripheral_reset_done) {
ESP_LOGV(TAG, "Resetting LEDC peripheral to clear stale state after reboot"); ESP_LOGV(TAG, "Resetting LEDC peripheral to clear stale state after reboot");
// Skip under clang-tidy: the inlined HAL MMIO writes trip clang-analyzer-core.FixedAddressDereference
#if !defined(CLANG_TIDY)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 1, 0) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 1, 0)
PERIPH_RCC_ATOMIC() { ledc_ll_reset_register(0); } PERIPH_RCC_ATOMIC() { ledc_ll_reset_register(0); }
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0) #elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
@@ -174,6 +176,7 @@ void LEDCOutput::setup() {
} }
#else #else
periph_module_reset(PERIPH_LEDC_MODULE); periph_module_reset(PERIPH_LEDC_MODULE);
#endif
#endif #endif
ledc_peripheral_reset_done = true; ledc_peripheral_reset_done = true;
} }

View File

@@ -132,10 +132,7 @@ extra_scripts = post:esphome/components/esp8266/post_build.py.script
; This are common settings for the ESP32 (all variants) using Arduino. ; This are common settings for the ESP32 (all variants) using Arduino.
[common:esp32-arduino] [common:esp32-arduino]
extends = common:arduino extends = common:arduino
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.39/platform-espressif32.zip platform = https://github.com/pioarduino/platform-espressif32.git
platform_packages =
pioarduino/framework-arduinoespressif32@https://github.com/espressif/arduino-esp32/releases/download/3.3.9/esp32-core-3.3.9.tar.xz
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.5.4/esp-idf-v5.5.4.tar.xz
framework = arduino, espidf ; Arduino as an ESP-IDF component framework = arduino, espidf ; Arduino as an ESP-IDF component
lib_deps = lib_deps =
@@ -167,9 +164,7 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
; This are common settings for the ESP32 (all variants) using IDF. ; This are common settings for the ESP32 (all variants) using IDF.
[common:esp32-idf] [common:esp32-idf]
extends = common:idf extends = common:idf
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.39/platform-espressif32.zip platform = https://github.com/pioarduino/platform-espressif32.git
platform_packages =
pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v5.5.4/esp-idf-v5.5.4.tar.xz
framework = espidf framework = espidf
lib_deps = lib_deps =

View File

@@ -73,6 +73,7 @@ def clang_options(idedata):
"-freorder-blocks", "-freorder-blocks",
"-fno-jump-tables", "-fno-jump-tables",
"-fno-shrink-wrap", "-fno-shrink-wrap",
"-mno-target-align",
) )
if "zephyr" in triplet: if "zephyr" in triplet:
@@ -137,6 +138,7 @@ def clang_options(idedata):
if flag not in omit_flags if flag not in omit_flags
and not flag.startswith("-Werror") and not flag.startswith("-Werror")
and not flag.startswith("-std=") and not flag.startswith("-std=")
and not flag.startswith("-mtune=esp")
) )
cmd.append("-std=gnu++20") cmd.append("-std=gnu++20")

View File

@@ -2,6 +2,14 @@
# (clang-tidy) -- by both the PlatformIO and the native ESP-IDF toolchain paths -- and when PlatformIO is run directly # (clang-tidy) -- by both the PlatformIO and the native ESP-IDF toolchain paths -- and when PlatformIO is run directly
# from the source directory (e.g. by IDEs). This should enable all flags that are set by any component. # from the source directory (e.g. by IDEs). This should enable all flags that are set by any component.
# clang-tidy analyzes with clang, and IDF 6 only offers newlib under clang
# (picolibc's Kconfig depends on !IDF_TOOLCHAIN_CLANG). The idedata is generated
# with GCC, whose default is picolibc -- but clang-tidy uses the toolchain's
# newlib headers, so a picolibc build config mismatches them (IDF's hal/assert.h
# redeclares abort()/__assert_func() with [[noreturn]] after newlib's stdlib.h,
# tripping clang-diagnostic-error). Pin newlib to match the analyzed headers.
CONFIG_LIBC_NEWLIB=y
# esp32 # esp32
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_FREERTOS_HZ=1000 CONFIG_FREERTOS_HZ=1000