Skip to content

Commit

Permalink
Merge pull request #517 from david-cermak/fix/examples_format_warn
Browse files Browse the repository at this point in the history
Fix remaining format warnings
  • Loading branch information
david-cermak authored Mar 5, 2024
2 parents dcdf311 + 302b46f commit 4977f96
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mdns__build-target-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
. ${IDF_PATH}/export.sh
python -m pip install idf-build-apps
# Build default configs for all targets
python ./ci/build_apps.py components/mdns/${{ matrix.test.path }} -r default -m components/mdns/.build-test-rules.yml -d
python ./ci/build_apps.py components/mdns/${{ matrix.test.path }} -r default -d
# Build specific configs for test targets
python ./ci/build_apps.py components/mdns/${{ matrix.test.path }}
cd components/mdns/${{ matrix.test.path }}
Expand Down
5 changes: 0 additions & 5 deletions components/esp_modem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 9 additions & 3 deletions components/esp_modem/src/esp_modem_cmux.cpp
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 0 additions & 11 deletions components/mdns/.build-test-rules.yml

This file was deleted.

8 changes: 4 additions & 4 deletions components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -5386,13 +5386,13 @@ static inline void set_default_duplicated_interfaces(void)

static inline void unregister_predefined_handlers(void)
{
#if defined(MDNS_ESP_WIFI_ENABLED) && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
#if MDNS_ESP_WIFI_ENABLED && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event);
#endif
#if CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP || CONFIG_MDNS_PREDEF_NETIF_ETH
esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event);
#endif
#if defined(CONFIG_ETH_ENABLED) && CONFIG_MDNS_PREDEF_NETIF_ETH
#if CONFIG_ETH_ENABLED && CONFIG_MDNS_PREDEF_NETIF_ETH
esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event);
#endif
}
Expand Down Expand Up @@ -5483,7 +5483,7 @@ esp_err_t mdns_init(void)
goto free_queue;
}

#if defined(MDNS_ESP_WIFI_ENABLED) && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
#if MDNS_ESP_WIFI_ENABLED && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
if ((err = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event, NULL)) != ESP_OK) {
goto free_event_handlers;
}
Expand All @@ -5493,7 +5493,7 @@ esp_err_t mdns_init(void)
goto free_event_handlers;
}
#endif
#if defined(CONFIG_ETH_ENABLED) && CONFIG_MDNS_PREDEF_NETIF_ETH
#if CONFIG_ETH_ENABLED && CONFIG_MDNS_PREDEF_NETIF_ETH
if ((err = esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event, NULL)) != ESP_OK) {
goto free_event_handlers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ idf_component_register(
INCLUDE_DIRS "include"
REQUIRES esp_netif driver
)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <string.h>
#include <inttypes.h>
#include "slip_modem.h"

#include "esp_netif.h"
Expand Down Expand Up @@ -176,7 +177,7 @@ static esp_err_t slip_modem_transmit(void *slip_driver, void *buffer, size_t len
int32_t res = uart_write_bytes(slip_modem->uart.uart_dev, (char *)buffer, len);
if (res < 0) {
// Handle errors
ESP_LOGE(TAG, "%s: uart_write_bytes error %i", __func__, res);
ESP_LOGE(TAG, "%s: uart_write_bytes error %" PRId32, __func__, res);
return ESP_FAIL;
}
return ESP_OK;
Expand Down Expand Up @@ -212,7 +213,7 @@ static void slip_modem_uart_rx_task(void *arg)
slip_modem_handle slip_modem = (slip_modem_handle) arg;

ESP_LOGD(TAG, "Start SLIP modem RX task (slip_modem %p filter: %p)", slip_modem, slip_modem->rx_filter);
ESP_LOGD(TAG, "Uart: %d, buffer: %p (%d bytes)", slip_modem->uart.uart_dev, slip_modem->buffer, slip_modem->buffer_len);
ESP_LOGD(TAG, "Uart: %d, buffer: %p (%" PRIu32 " bytes)", slip_modem->uart.uart_dev, slip_modem->buffer, slip_modem->buffer_len);

while (slip_modem->running == true) {
// Read data from the UART
Expand Down
1 change: 0 additions & 1 deletion examples/esp_netif/slip_custom_netif/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ idf_component_register(
INCLUDE_DIRS "."
REQUIRES esp_netif slip_modem driver
)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void slip_set_prefix(slip_modem_handle slip)
{
uint8_t buff[10] = {0};
const esp_ip6_addr_t addr = slip_modem_get_ipv6_address(slip);
ESP_LOGI(TAG, "%s: prefix set (%08x:%08x)", __func__,
ESP_LOGI(TAG, "%s: prefix set (%08" PRIx32 ":%08" PRIx32 ")", __func__,
lwip_ntohl(addr.addr[0]), lwip_ntohl(addr.addr[1]));

// Build slip set message
Expand Down
2 changes: 0 additions & 2 deletions examples/mqtt/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
idf_component_register(SRCS "app_main.cpp"
INCLUDE_DIRS ".")

target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
10 changes: 5 additions & 5 deletions examples/mqtt/main/app_main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
Expand Down Expand Up @@ -40,8 +40,8 @@ static void log_error_if_nonzero(const char *message, int error_code)
*/
static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
{
ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data;
ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id);
auto event = (esp_mqtt_event_handle_t)event_data;
esp_mqtt_client_handle_t client = event->client;
int msg_id;
switch ((esp_mqtt_event_id_t)event_id) {
Expand Down Expand Up @@ -95,7 +95,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
}
}

static void mqtt_app_start(void)
static void mqtt_app_start()
{
esp_mqtt_client_config_t mqtt_cfg = {};
mqtt_cfg.broker.address.uri = CONFIG_BROKER_URL;
Expand All @@ -111,7 +111,7 @@ static void mqtt_app_start(void)
extern "C" void app_main(void)
{
ESP_LOGI(TAG, "[APP] Startup..");
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
ESP_LOGI(TAG, "[APP] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size());
ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version());

esp_log_level_set("*", ESP_LOG_INFO);
Expand Down

0 comments on commit 4977f96

Please sign in to comment.