From 64eb3a28b629548cb80a6f4c5f39843002ad418d Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 3 Jun 2021 12:58:44 +0200 Subject: [PATCH 1/5] Build: Fix CMake to pass -Wwrite-string compiler flag if enabled --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7e499304b..8ac1b91ac5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,10 @@ if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS) "-Wno-int-in-bool-context") endif() +if(CONFIG_COMPILER_WARN_WRITE_STRINGS) + list(APPEND compile_options "-Wwrite-strings") +endif() + if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE) list(APPEND compile_definitions "-DNDEBUG") endif() From c805a5cff82e406ab88c47b4b659c9832b590ffd Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 4 Jun 2021 13:23:24 +0200 Subject: [PATCH 2/5] wpa_supplicant: Temporarily disable write-string warning Since some assignment of a string literal to `char *` variables were added and not caught by the CI. --- components/wpa_supplicant/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/wpa_supplicant/CMakeLists.txt b/components/wpa_supplicant/CMakeLists.txt index 220a0ccd76..2e10bb82af 100644 --- a/components/wpa_supplicant/CMakeLists.txt +++ b/components/wpa_supplicant/CMakeLists.txt @@ -157,7 +157,7 @@ idf_component_register(SRCS "${srcs}" "${tls_src}" "${roaming_src}" "${crypto_sr PRIV_INCLUDE_DIRS src src/utils PRIV_REQUIRES mbedtls esp_timer) -target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing) +target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing -Wno-write-strings) target_compile_definitions(${COMPONENT_LIB} PRIVATE __ets__ ESP_SUPPLICANT From e7500c711d6c084bc7cfbabe2372ec6107b35fb0 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 4 Jun 2021 14:37:41 +0200 Subject: [PATCH 3/5] rtc: Fix minor const char* correction issue --- components/esp_hw_support/port/esp32s3/rtc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_hw_support/port/esp32s3/rtc_init.c b/components/esp_hw_support/port/esp32s3/rtc_init.c index 0662c6b757..01b62a12e7 100644 --- a/components/esp_hw_support/port/esp32s3/rtc_init.c +++ b/components/esp_hw_support/port/esp32s3/rtc_init.c @@ -27,7 +27,7 @@ #define RTC_CNTL_MEM_FORCE_PU (RTC_CNTL_SLOWMEM_FORCE_PU | RTC_CNTL_FASTMEM_FORCE_PU) #define RTC_CNTL_MEM_FORCE_NOISO (RTC_CNTL_SLOWMEM_FORCE_NOISO | RTC_CNTL_FASTMEM_FORCE_NOISO) -static char *TAG = "rtcinit"; +static const char *TAG = "rtcinit"; void rtc_init(rtc_config_t cfg) { From dd1de2121646e0c2cce67e4c0df5b655610ddd92 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 18 Aug 2021 12:59:15 +0200 Subject: [PATCH 4/5] panic/memprot: Fix minor const string correction on panic print --- components/esp_system/port/arch/xtensa/panic_arch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_system/port/arch/xtensa/panic_arch.c b/components/esp_system/port/arch/xtensa/panic_arch.c index 9576eb8855..a61753c7ed 100644 --- a/components/esp_system/port/arch/xtensa/panic_arch.c +++ b/components/esp_system/port/arch/xtensa/panic_arch.c @@ -273,7 +273,7 @@ static inline void print_memprot_err_details(const void *f) mem_type_prot_t mem_type = esp_memprot_get_active_intr_memtype(); esp_memprot_get_fault_status( mem_type, &fault_addr, &op_type, &op_subtype ); - char *operation_type = "Write"; + const char *operation_type = "Write"; if ( op_type == 0 ) { operation_type = (mem_type == MEMPROT_IRAM0_SRAM && op_subtype == 0) ? "Instruction fetch" : "Read"; } From 7f8d47203effee3625aab6e3b916dcedafee3797 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 30 Dec 2020 05:33:51 +0100 Subject: [PATCH 5/5] ci/test: Fix esp_http_client const char* correction --- components/esp_http_client/test/test_http_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_http_client/test/test_http_client.c b/components/esp_http_client/test/test_http_client.c index a387e7d892..504c42e1a9 100644 --- a/components/esp_http_client/test/test_http_client.c +++ b/components/esp_http_client/test/test_http_client.c @@ -127,7 +127,7 @@ TEST_CASE("Username and password will not reset if new absolute URL doesnot spec // esp_http_client_set_username sets new username and thus invalidates the original one // which we still reference in the local variable `value` (better forget it) value = NULL; - esp_http_client_set_password(client, USERNAME); + esp_http_client_set_password(client, (char *)USERNAME); // Need to cast the string literal (argument is not a const char*) //checks if username is set or not r = esp_http_client_get_username(client, &value); TEST_ASSERT_EQUAL(ESP_OK, r);