From 3b80181d30d747e95541860d6beccfeb2c609b29 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 28 Feb 2024 19:24:52 +0100 Subject: [PATCH] fix(modem): Fix remaining print format warnings Partially addresses https://github.com/espressif/esp-protocols/issues/79 --- components/esp_modem/CMakeLists.txt | 5 ----- components/esp_modem/src/esp_modem_cmux.cpp | 12 +++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/esp_modem/CMakeLists.txt b/components/esp_modem/CMakeLists.txt index 447d94af7..fbede4026 100644 --- a/components/esp_modem/CMakeLists.txt +++ b/components/esp_modem/CMakeLists.txt @@ -45,8 +45,3 @@ set_target_properties(${COMPONENT_LIB} PROPERTIES if(CONFIG_ESP_MODEM_ADD_CUSTOM_MODULE) idf_component_optional_requires(PUBLIC main) endif() - -if(${target} STREQUAL "linux") - # This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64 - set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format) -endif() diff --git a/components/esp_modem/src/esp_modem_cmux.cpp b/components/esp_modem/src/esp_modem_cmux.cpp index a04c1808d..b1bfc7877 100644 --- a/components/esp_modem/src/esp_modem_cmux.cpp +++ b/components/esp_modem/src/esp_modem_cmux.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,6 +13,12 @@ using namespace esp_modem; +#ifdef CONFIG_IDF_TARGET_LINUX +#define PRIsize_t "lu" +#else +#define PRIsize_t "u" +#endif + #ifdef CONFIG_ESP_MODEM_CMUX_DEFRAGMENT_PAYLOAD /** * @brief Define this to defragment partially received data of CMUX payload @@ -245,7 +251,7 @@ bool CMux::on_header(CMuxFrame &frame) bool CMux::on_payload(CMuxFrame &frame) { - ESP_LOGD("CMUX", "Payload frame: dlci:%02x type:%02x payload:%d available:%d", dlci, type, payload_len, frame.len); + ESP_LOGD("CMUX", "Payload frame: dlci:%02x type:%02x payload:%" PRIsize_t " available:%" PRIsize_t, dlci, type, payload_len, frame.len); if (frame.len < payload_len) { // payload state = cmux_state::PAYLOAD; if (!data_available(frame.ptr, frame.len)) { // partial read @@ -312,7 +318,7 @@ bool CMux::on_cmux_data(uint8_t *data, size_t actual_len) auto data_end = buffer.get() + buffer.size; data_to_read = payload_len + 2; // 2 -- CMUX protocol footer if (data + data_to_read >= data_end) { - ESP_LOGW("CUMX", "Failed to defragment longer payload (payload=%d)", payload_len); + ESP_LOGW("CUMX", "Failed to defragment longer payload (payload=%" PRIsize_t ")", payload_len); // If you experience this error, your device uses longer payloads while // the configured buffer is too small to defragment the payload properly. // To resolve this issue you can: