From 40c1529b4bbb066a02ef8744678ca0b49865d964 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Fri, 2 Sep 2022 16:53:45 +0530 Subject: [PATCH] bootloader_support: fix stringop-overflow warning with `PERF` compiler optimization This commit fixes build issue because of function `bootloader_common_reset_rtc_retain_mem` getting inlined with compiler optimization level set to `PERF` (-O2). Build failure log: ----------------- In function 'bootloader_common_reset_rtc_retain_mem', inlined from 'bootloader_common_update_rtc_retain_mem' at /h/esp-idf/components/bootloader_support/src/bootloader_common_loader.c:183:13: /h/esp-idf/components/bootloader_support/src/bootloader_common_loader.c:159:5: error: 'memset' writing 16 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] 159 | memset(rtc_retain_mem, 0, sizeof(rtc_retain_mem_t)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- components/bootloader_support/src/bootloader_common_loader.c | 2 +- .../system/bootloader_sections/sdkconfig.ci.rtc_retain | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/bootloader_support/src/bootloader_common_loader.c b/components/bootloader_support/src/bootloader_common_loader.c index 7bc3571127..34810d7124 100644 --- a/components/bootloader_support/src/bootloader_common_loader.c +++ b/components/bootloader_support/src/bootloader_common_loader.c @@ -138,7 +138,7 @@ static void update_rtc_retain_mem_crc(void) rtc_retain_mem->crc = esp_rom_crc32_le(UINT32_MAX, (uint8_t*)rtc_retain_mem, sizeof(rtc_retain_mem_t) - sizeof(rtc_retain_mem->crc)); } -void bootloader_common_reset_rtc_retain_mem(void) +NOINLINE_ATTR void bootloader_common_reset_rtc_retain_mem(void) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" diff --git a/tools/test_apps/system/bootloader_sections/sdkconfig.ci.rtc_retain b/tools/test_apps/system/bootloader_sections/sdkconfig.ci.rtc_retain index 3ba7ab36b7..5476981755 100644 --- a/tools/test_apps/system/bootloader_sections/sdkconfig.ci.rtc_retain +++ b/tools/test_apps/system/bootloader_sections/sdkconfig.ci.rtc_retain @@ -1 +1,2 @@ CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y +CONFIG_COMPILER_OPTIMIZATION_PERF=y