From d1db4d0c1b07d261bc35599a5ab654c82de7c1d5 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Mon, 21 Feb 2022 16:49:41 +0700 Subject: [PATCH 1/8] system: add missing header --- components/xtensa/include/xtensa-debug-module.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/xtensa/include/xtensa-debug-module.h b/components/xtensa/include/xtensa-debug-module.h index d1aca40d5b..17e5a2e355 100644 --- a/components/xtensa/include/xtensa-debug-module.h +++ b/components/xtensa/include/xtensa-debug-module.h @@ -1,6 +1,8 @@ #ifndef XTENSA_DEBUG_MODULE_H #define XTENSA_DEBUG_MODULE_H +#include + /* ERI registers / OCD offsets and field definitions */ From 8ea1a2b1e8d3969964d4ed1208c27dde5097dec7 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 22 Feb 2022 09:48:06 +0700 Subject: [PATCH 2/8] pthread: add missing header --- components/pthread/test/test_pthread_cxx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/pthread/test/test_pthread_cxx.cpp b/components/pthread/test/test_pthread_cxx.cpp index 0943190d37..b7cfbb275c 100644 --- a/components/pthread/test/test_pthread_cxx.cpp +++ b/components/pthread/test/test_pthread_cxx.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "unity.h" From f57016dab0f8331ab63b6200ee40d83447754d62 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 22 Feb 2022 13:39:11 +0700 Subject: [PATCH 3/8] esp_hw_support: explicit initialization --- components/esp_hw_support/test/test_ds.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/components/esp_hw_support/test/test_ds.c b/components/esp_hw_support/test/test_ds.c index 2a69e1e8dc..23c94d45f3 100644 --- a/components/esp_hw_support/test/test_ds.c +++ b/components/esp_hw_support/test/test_ds.c @@ -59,36 +59,36 @@ _Static_assert(NUM_RESULTS == NUM_MESSAGES, "expected_results size should be the TEST_CASE("Digital Signature Parameter Encryption data NULL", "[hw_crypto] [ds]") { - const char iv [32]; - esp_ds_p_data_t p_data; - const char key [32]; + const char iv [32] = {0}; + esp_ds_p_data_t p_data = {0}; + const char key [32] = {0}; TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_encrypt_params(NULL, iv, &p_data, key)); } TEST_CASE("Digital Signature Parameter Encryption iv NULL", "[hw_crypto] [ds]") { - esp_ds_data_t data; - esp_ds_p_data_t p_data; - const char key [32]; + esp_ds_data_t data = {0}; + esp_ds_p_data_t p_data = {0}; + const char key [32] = {0}; TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_encrypt_params(&data, NULL, &p_data, key)); } TEST_CASE("Digital Signature Parameter Encryption p_data NULL", "[hw_crypto] [ds]") { - esp_ds_data_t data; - const char iv [32]; - const char key [32]; + esp_ds_data_t data = {0}; + const char iv [32] = {0}; + const char key [32] = {0}; TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_encrypt_params(&data, iv, NULL, key)); } TEST_CASE("Digital Signature Parameter Encryption key NULL", "[hw_crypto] [ds]") { - esp_ds_data_t data; - const char iv [32]; - esp_ds_p_data_t p_data; + esp_ds_data_t data = {0}; + const char iv [32] = {0}; + esp_ds_p_data_t p_data = {0}; TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, esp_ds_encrypt_params(&data, iv, &p_data, NULL)); } From 0c549320b2e77d5fb5135ff91ce2dc9980a3ad01 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Mon, 30 May 2022 12:13:23 +0700 Subject: [PATCH 4/8] esp_system: intentionally suppress -Wstringop-overread --- components/esp_system/port/cpu_start.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index cfd8fceccc..57cf190372 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -613,7 +613,14 @@ void IRAM_ATTR call_start_cpu0(void) #else // This assumes that DROM is the first segment in the application binary, i.e. that we can read // the binary header through cache by accessing SOC_DROM_LOW address. +#pragma GCC diagnostic push +#if __GNUC__ >= 11 +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif +#pragma GCC diagnostic ignored "-Warray-bounds" memcpy(&fhdr, (void *) SOC_DROM_LOW, sizeof(fhdr)); +#pragma GCC diagnostic pop + #endif // CONFIG_APP_BUILD_TYPE_ELF_RAM #if CONFIG_IDF_TARGET_ESP32 From afde2434e8323373ca5bdea759fa3eb281c2948b Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Wed, 23 Feb 2022 18:43:16 +0700 Subject: [PATCH 5/8] memprot: fix type casting to avoid suspesious address arithmetic --- components/esp_hw_support/port/esp32c3/esp_memprot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_hw_support/port/esp32c3/esp_memprot.c b/components/esp_hw_support/port/esp32c3/esp_memprot.c index d62311f884..762d661706 100644 --- a/components/esp_hw_support/port/esp32c3/esp_memprot.c +++ b/components/esp_hw_support/port/esp32c3/esp_memprot.c @@ -28,7 +28,7 @@ static void *esp_memprot_iram0_get_def_split_addr(void) static void *esp_memprot_dram0_get_def_split_addr(void) { - return MAP_IRAM_TO_DRAM(&_iram_text_end); + return (void *)MAP_IRAM_TO_DRAM((uint32_t)&_iram_text_end); } static void *esp_memprot_rtcfast_get_min_split_addr(void) From bf3892acee49ae8b782e203bf04d58b36076f94b Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Fri, 13 May 2022 13:33:04 +0700 Subject: [PATCH 6/8] newlib: stdatomic: fix conflicting types for __atomic_load/__atomic_store --- components/newlib/stdatomic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/newlib/stdatomic.c b/components/newlib/stdatomic.c index f4b2bca371..08f8877158 100644 --- a/components/newlib/stdatomic.c +++ b/components/newlib/stdatomic.c @@ -497,16 +497,16 @@ ATOMIC_STORE(8, long long unsigned int) #endif // !HAS_ATOMICS_64 // Clang generates calls to the __atomic_load/__atomic_store functions for object size more then 4 bytes -void CLANG_ATOMIC_SUFFIX( __atomic_load ) (int size, void *src, void *dest, int model) { +void CLANG_ATOMIC_SUFFIX( __atomic_load ) (size_t size, const volatile void *src, void *dest, int model) { unsigned state = _ATOMIC_ENTER_CRITICAL(); - memcpy(dest, src, size); + memcpy(dest, (const void *)src, size); _ATOMIC_EXIT_CRITICAL(state); } CLANG_DECLARE_ALIAS( __atomic_load ) -void CLANG_ATOMIC_SUFFIX( __atomic_store ) (int size, void *dest, void *src, int model) { +void CLANG_ATOMIC_SUFFIX( __atomic_store ) (size_t size, volatile void *dest, void *src, int model) { unsigned state = _ATOMIC_ENTER_CRITICAL(); - memcpy(dest, src, size); + memcpy((void *)dest, (const void *)src, size); _ATOMIC_EXIT_CRITICAL(state); } CLANG_DECLARE_ALIAS( __atomic_store) From 1f5bb083b94f3772b1110a8c356909129ada14b8 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Tue, 24 May 2022 16:04:57 +0700 Subject: [PATCH 7/8] examples, timer: use llabs() 64-bit argument --- examples/system/esp_timer/main/esp_timer_example_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/system/esp_timer/main/esp_timer_example_main.c b/examples/system/esp_timer/main/esp_timer_example_main.c index bccb6e0bb2..6aa5093ac2 100644 --- a/examples/system/esp_timer/main/esp_timer_example_main.c +++ b/examples/system/esp_timer/main/esp_timer_example_main.c @@ -70,7 +70,7 @@ void app_main(void) int64_t t2 = esp_timer_get_time(); ESP_LOGI(TAG, "Woke up from light sleep, time since boot: %lld us", t2); - assert(abs((t2 - t1) - 500000) < 1000); + assert(llabs((t2 - t1) - 500000) < 1000); /* Let the timer run for a little bit more */ usleep(2000000); From 84879a8e9cf62fc19478e25f035fad3bc55e5ce8 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Thu, 20 Jan 2022 09:30:00 +0700 Subject: [PATCH 8/8] esp_rom: esp32s2: suppress -Waddress-of-packed-member warning --- components/esp_rom/esp32s2/usb_descriptors.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/esp_rom/esp32s2/usb_descriptors.c b/components/esp_rom/esp32s2/usb_descriptors.c index cae0abdd9e..279930095d 100644 --- a/components/esp_rom/esp32s2/usb_descriptors.c +++ b/components/esp_rom/esp32s2/usb_descriptors.c @@ -49,6 +49,10 @@ void rom_usb_cdc_set_descriptor_patch(void) uint8_t mac_bytes[6]; efuse_hal_get_mac(mac_bytes); /* Convert to UTF16 string */ +#pragma GCC diagnostic push +#if __GNUC__ >= 9 +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif uint16_t* dst = s_str_serial_descr.bString; for (int i = 0; i < 6; ++i) { uint8_t b = mac_bytes[5 - i]; /* printing from the MSB */ @@ -56,6 +60,7 @@ void rom_usb_cdc_set_descriptor_patch(void) *dst++ = nibble_to_hex_u16(b & 0xf); dst++; } +#pragma GCC diagnostic pop /* Override the pointer to descriptors structure */ rom_usb_curr_desc = &s_acm_usb_descriptors_override;