From d173d72a3f576c1baa54f4632e335434a45197da Mon Sep 17 00:00:00 2001 From: Suren Gabrielyan Date: Thu, 20 Jul 2023 13:48:50 +0400 Subject: [PATCH] fix(common): removed Wno-format flag and fixed formatting warnings --- components/asio/CMakeLists.txt | 1 - .../esp_modem/examples/modem_console/main/CMakeLists.txt | 1 - .../examples/modem_console/main/modem_console_main.cpp | 4 ++-- .../esp_modem/examples/modem_console/main/ping_handle.c | 6 +++--- components/esp_modem/examples/modem_psm/main/CMakeLists.txt | 1 - .../esp_modem/examples/modem_tcp_client/main/CMakeLists.txt | 1 - .../esp_modem/examples/pppos_client/main/CMakeLists.txt | 1 - .../examples/pppos_client/main/pppos_client_main.c | 6 +++--- components/esp_modem/test/target/main/CMakeLists.txt | 2 -- components/esp_modem/test/target/main/pppd_test.cpp | 6 +++--- components/esp_mqtt_cxx/CMakeLists.txt | 2 -- components/esp_mqtt_cxx/esp_mqtt_cxx.cpp | 2 +- components/esp_mqtt_cxx/examples/ssl/main/CMakeLists.txt | 1 - .../esp_mqtt_cxx/examples/ssl/main/mqtt_ssl_example.cpp | 2 +- components/esp_mqtt_cxx/examples/tcp/main/CMakeLists.txt | 1 - .../esp_mqtt_cxx/examples/tcp/main/mqtt_tcp_example.cpp | 2 +- components/mdns/CMakeLists.txt | 1 - components/mdns/examples/main/CMakeLists.txt | 1 - components/mdns/examples/main/mdns_example_main.c | 2 +- components/mdns/mdns.c | 4 ++-- components/mdns/mdns_networking_socket.c | 2 +- components/mdns/private_include/mdns_private.h | 2 +- components/mdns/tests/test_apps/main/CMakeLists.txt | 1 - components/mdns/tests/test_apps/main/main.c | 2 +- 24 files changed, 20 insertions(+), 34 deletions(-) diff --git a/components/asio/CMakeLists.txt b/components/asio/CMakeLists.txt index 528308c9c7a..33665459703 100644 --- a/components/asio/CMakeLists.txt +++ b/components/asio/CMakeLists.txt @@ -27,7 +27,6 @@ idf_component_register(SRCS ${asio_sources} INCLUDE_DIRS "asio/asio/include" "port/include" PRIV_INCLUDE_DIRS ${asio_priv_includes} REQUIRES lwip) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") if(CONFIG_ASIO_SSL_SUPPORT) if(CONFIG_ASIO_USE_ESP_WOLFSSL) diff --git a/components/esp_modem/examples/modem_console/main/CMakeLists.txt b/components/esp_modem/examples/modem_console/main/CMakeLists.txt index e09da6eb3f8..2465c0aec4d 100644 --- a/components/esp_modem/examples/modem_console/main/CMakeLists.txt +++ b/components/esp_modem/examples/modem_console/main/CMakeLists.txt @@ -5,4 +5,3 @@ idf_component_register(SRCS "modem_console_main.cpp" "ping_handle.c" REQUIRES console esp_http_client nvs_flash INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_modem/examples/modem_console/main/modem_console_main.cpp b/components/esp_modem/examples/modem_console/main/modem_console_main.cpp index 2f8052e0e45..249d0061456 100644 --- a/components/esp_modem/examples/modem_console/main/modem_console_main.cpp +++ b/components/esp_modem/examples/modem_console/main/modem_console_main.cpp @@ -173,7 +173,7 @@ extern "C" void app_main(void) ESP_LOGI(TAG, "Waiting for USB device connection..."); auto dte = create_usb_dte(&dte_config); dte->set_error_cb([&](terminal_error err) { - ESP_LOGI(TAG, "error handler %d", err); + ESP_LOGI(TAG, "error handler %d", (int)err); if (err == terminal_error::DEVICE_GONE) { exit_signal.set(1); } @@ -482,7 +482,7 @@ extern "C" void app_main(void) // wait for exit exit_signal.wait_any(1, UINT32_MAX); s_repl->del(s_repl); - ESP_LOGI(TAG, "Exiting...%d", esp_get_free_heap_size()); + ESP_LOGI(TAG, "Exiting...%" PRIu32, esp_get_free_heap_size()); #if defined(CONFIG_EXAMPLE_SERIAL_CONFIG_USB) // USB example runs in a loop to demonstrate hot-plugging and sudden disconnection features. } // while (1) diff --git a/components/esp_modem/examples/modem_console/main/ping_handle.c b/components/esp_modem/examples/modem_console/main/ping_handle.c index 1e247786538..7163ebfb21a 100644 --- a/components/esp_modem/examples/modem_console/main/ping_handle.c +++ b/components/esp_modem/examples/modem_console/main/ping_handle.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -28,7 +28,7 @@ static void cmd_ping_on_ping_success(esp_ping_handle_t hdl, void *args) esp_ping_get_profile(hdl, ESP_PING_PROF_IPADDR, &target_addr, sizeof(target_addr)); esp_ping_get_profile(hdl, ESP_PING_PROF_SIZE, &recv_len, sizeof(recv_len)); esp_ping_get_profile(hdl, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time)); - ESP_LOGI(TAG, "%d bytes from %s icmp_seq=%d ttl=%d time=%d ms\n", + ESP_LOGI(TAG, "%" PRIu32 " bytes from %s icmp_seq=%d ttl=%d time=%" PRIu32 " ms\n", recv_len, inet_ntoa(target_addr.u_addr.ip4), seqno, ttl, elapsed_time); } @@ -57,7 +57,7 @@ static void cmd_ping_on_ping_end(esp_ping_handle_t hdl, void *args) } else { ESP_LOGI(TAG, "\n--- %s ping statistics ---\n", inet6_ntoa(*ip_2_ip6(&target_addr))); } - ESP_LOGI(TAG, "%d packets transmitted, %d received, %d%% packet loss, time %dms\n", + ESP_LOGI(TAG, "%" PRIu32 " packets transmitted, %" PRIu32 " received, %" PRIu32 " packet loss, time %" PRIu32 "ms\n", transmitted, received, loss, total_time_ms); // delete the ping sessions, so that we clean up all resources and can create a new ping session // we don't have to call delete function in the callback, instead we can call delete function from other tasks diff --git a/components/esp_modem/examples/modem_psm/main/CMakeLists.txt b/components/esp_modem/examples/modem_psm/main/CMakeLists.txt index cf40f6aecb7..75d5c06cf37 100644 --- a/components/esp_modem/examples/modem_psm/main/CMakeLists.txt +++ b/components/esp_modem/examples/modem_psm/main/CMakeLists.txt @@ -1,3 +1,2 @@ - idf_component_register(SRCS "modem_psm.c" INCLUDE_DIRS ".") diff --git a/components/esp_modem/examples/modem_tcp_client/main/CMakeLists.txt b/components/esp_modem/examples/modem_tcp_client/main/CMakeLists.txt index b7d3874ab19..5aeaaf28e9e 100644 --- a/components/esp_modem/examples/modem_tcp_client/main/CMakeLists.txt +++ b/components/esp_modem/examples/modem_tcp_client/main/CMakeLists.txt @@ -8,4 +8,3 @@ idf_component_register(SRCS "modem_client.cpp" "sock_dce.cpp" "${device_srcs}" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_modem/examples/pppos_client/main/CMakeLists.txt b/components/esp_modem/examples/pppos_client/main/CMakeLists.txt index ff0f8ff5801..679e282a079 100644 --- a/components/esp_modem/examples/pppos_client/main/CMakeLists.txt +++ b/components/esp_modem/examples/pppos_client/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "pppos_client_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_modem/examples/pppos_client/main/pppos_client_main.c b/components/esp_modem/examples/pppos_client/main/pppos_client_main.c index 1b0132776ed..cb5ff954adb 100644 --- a/components/esp_modem/examples/pppos_client/main/pppos_client_main.c +++ b/components/esp_modem/examples/pppos_client/main/pppos_client_main.c @@ -60,7 +60,7 @@ if ((xEventGroupGetBits(event_group) & USB_DISCONNECTED_BIT) == USB_DISCONNECTED 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_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIu32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -102,7 +102,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_ static void on_ppp_changed(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { - ESP_LOGI(TAG, "PPP state changed event %d", event_id); + ESP_LOGI(TAG, "PPP state changed event %" PRIu32, event_id); if (event_id == NETIF_PPP_ERRORUSER) { /* User interrupted event from esp-netif */ esp_netif_t *netif = event_data; @@ -114,7 +114,7 @@ static void on_ppp_changed(void *arg, esp_event_base_t event_base, static void on_ip_event(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { - ESP_LOGD(TAG, "IP event! %d", event_id); + ESP_LOGD(TAG, "IP event! %" PRIu32, event_id); if (event_id == IP_EVENT_PPP_GOT_IP) { esp_netif_dns_info_t dns_info; diff --git a/components/esp_modem/test/target/main/CMakeLists.txt b/components/esp_modem/test/target/main/CMakeLists.txt index 12a1ae84923..37807fcf435 100644 --- a/components/esp_modem/test/target/main/CMakeLists.txt +++ b/components/esp_modem/test/target/main/CMakeLists.txt @@ -8,5 +8,3 @@ set_target_properties(${COMPONENT_LIB} PROPERTIES CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON ) - -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_modem/test/target/main/pppd_test.cpp b/components/esp_modem/test/target/main/pppd_test.cpp index 36df491596d..8a4d6f1bd1c 100644 --- a/components/esp_modem/test/target/main/pppd_test.cpp +++ b/components/esp_modem/test/target/main/pppd_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -27,7 +27,7 @@ static void on_modem_event(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { if (event_base == IP_EVENT) { - ESP_LOGD(TAG, "IP event! %d", event_id); + ESP_LOGD(TAG, "IP event! %" PRId32, event_id); if (event_id == IP_EVENT_PPP_GOT_IP) { esp_netif_dns_info_t dns_info; @@ -61,7 +61,7 @@ static void on_modem_event(void *arg, esp_event_base_t event_base, static void on_ppp_changed(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { - ESP_LOGI(TAG, "PPP state changed event %d", event_id); + ESP_LOGI(TAG, "PPP state changed event %" PRId32, event_id); if (event_id == NETIF_PPP_ERRORUSER) { /* User interrupted event from esp-netif */ esp_netif_t *netif = static_cast(event_data); diff --git a/components/esp_mqtt_cxx/CMakeLists.txt b/components/esp_mqtt_cxx/CMakeLists.txt index d5fc7eded66..4fdb71ab2fb 100644 --- a/components/esp_mqtt_cxx/CMakeLists.txt +++ b/components/esp_mqtt_cxx/CMakeLists.txt @@ -4,5 +4,3 @@ idf_component_register(SRCS "esp_mqtt_cxx.cpp" INCLUDE_DIRS "include" REQUIRES mqtt ) - -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_mqtt_cxx/esp_mqtt_cxx.cpp b/components/esp_mqtt_cxx/esp_mqtt_cxx.cpp index 7e6145c5ac5..b1644bc854e 100644 --- a/components/esp_mqtt_cxx/esp_mqtt_cxx.cpp +++ b/components/esp_mqtt_cxx/esp_mqtt_cxx.cpp @@ -153,7 +153,7 @@ Client::Client(esp_mqtt_client_config_t const &config) : handler(esp_mqtt_clien void Client::mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) noexcept { - ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id); + ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIu32, base, event_id); auto *event = static_cast(event_data); auto &client = *static_cast(handler_args); switch (event->event_id) { diff --git a/components/esp_mqtt_cxx/examples/ssl/main/CMakeLists.txt b/components/esp_mqtt_cxx/examples/ssl/main/CMakeLists.txt index 020135ce8dc..e06e5975be1 100644 --- a/components/esp_mqtt_cxx/examples/ssl/main/CMakeLists.txt +++ b/components/esp_mqtt_cxx/examples/ssl/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "mqtt_ssl_example.cpp" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_mqtt_cxx/examples/ssl/main/mqtt_ssl_example.cpp b/components/esp_mqtt_cxx/examples/ssl/main/mqtt_ssl_example.cpp index ecd420c4b7a..3bdf35640da 100644 --- a/components/esp_mqtt_cxx/examples/ssl/main/mqtt_ssl_example.cpp +++ b/components/esp_mqtt_cxx/examples/ssl/main/mqtt_ssl_example.cpp @@ -54,7 +54,7 @@ namespace mqtt = idf::mqtt; 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); diff --git a/components/esp_mqtt_cxx/examples/tcp/main/CMakeLists.txt b/components/esp_mqtt_cxx/examples/tcp/main/CMakeLists.txt index f9c2aeec832..eeaa9534e54 100644 --- a/components/esp_mqtt_cxx/examples/tcp/main/CMakeLists.txt +++ b/components/esp_mqtt_cxx/examples/tcp/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "mqtt_tcp_example.cpp" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_mqtt_cxx/examples/tcp/main/mqtt_tcp_example.cpp b/components/esp_mqtt_cxx/examples/tcp/main/mqtt_tcp_example.cpp index bd749c50c2e..67517d246d0 100644 --- a/components/esp_mqtt_cxx/examples/tcp/main/mqtt_tcp_example.cpp +++ b/components/esp_mqtt_cxx/examples/tcp/main/mqtt_tcp_example.cpp @@ -49,7 +49,7 @@ class MyClient final : public mqtt::Client { 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); diff --git a/components/mdns/CMakeLists.txt b/components/mdns/CMakeLists.txt index 7551f38bf55..542edb58541 100644 --- a/components/mdns/CMakeLists.txt +++ b/components/mdns/CMakeLists.txt @@ -20,7 +20,6 @@ idf_component_register( PRIV_INCLUDE_DIRS "private_include" REQUIRES ${dependencies} PRIV_REQUIRES ${private_dependencies}) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") if(${target} STREQUAL "linux") target_link_libraries(${COMPONENT_LIB} PRIVATE "-lbsd") diff --git a/components/mdns/examples/main/CMakeLists.txt b/components/mdns/examples/main/CMakeLists.txt index 27c93ff5d22..eb0e6d9eb4a 100644 --- a/components/mdns/examples/main/CMakeLists.txt +++ b/components/mdns/examples/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "mdns_example_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/mdns/examples/main/mdns_example_main.c b/components/mdns/examples/main/mdns_example_main.c index e08c08fc9e0..dec439bb4cb 100644 --- a/components/mdns/examples/main/mdns_example_main.c +++ b/components/mdns/examples/main/mdns_example_main.c @@ -94,7 +94,7 @@ static void mdns_print_results(mdns_result_t *results) int i = 1, t; while (r) { if (r->esp_netif) { - printf("%d: Interface: %s, Type: %s, TTL: %u\n", i++, esp_netif_get_ifkey(r->esp_netif), + printf("%d: Interface: %s, Type: %s, TTL: %" PRIu32 "\n", i++, esp_netif_get_ifkey(r->esp_netif), ip_protocol_str[r->ip_protocol], r->ttl); } if (r->instance_name) { diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 33b76cf1854..bfa3256b1f6 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -1476,7 +1476,7 @@ static void _mdns_dispatch_tx_packet(mdns_tx_packet_t *p) _mdns_set_u16(packet, MDNS_HEAD_ADDITIONAL_OFFSET, count); #ifdef MDNS_ENABLE_DEBUG - _mdns_dbg_printf("\nTX[%u][%u]: ", p->tcpip_if, p->ip_protocol); + _mdns_dbg_printf("\nTX[%zu][%u]: ", p->tcpip_if, p->ip_protocol); if (p->dst.type == ESP_IPADDR_TYPE_V4) { _mdns_dbg_printf("To: " IPSTR ":%u, ", IP2STR(&p->dst.u_addr.ip4), p->port); } else { @@ -3492,7 +3492,7 @@ void mdns_parse_packet(mdns_rx_packet_t *packet) mdns_search_once_t *search_result = NULL; #ifdef MDNS_ENABLE_DEBUG - _mdns_dbg_printf("\nRX[%u][%u]: ", packet->tcpip_if, (uint32_t)packet->ip_protocol); + _mdns_dbg_printf("\nRX[%zu][%u]: ", packet->tcpip_if, (uint32_t)packet->ip_protocol); if (packet->src.type == ESP_IPADDR_TYPE_V4) { _mdns_dbg_printf("From: " IPSTR ":%u, To: " IPSTR ", ", IP2STR(&packet->src.u_addr.ip4), packet->src_port, IP2STR(&packet->dest.u_addr.ip4)); } else { diff --git a/components/mdns/mdns_networking_socket.c b/components/mdns/mdns_networking_socket.c index 2a62de384ea..542cc88aaa5 100644 --- a/components/mdns/mdns_networking_socket.c +++ b/components/mdns/mdns_networking_socket.c @@ -372,7 +372,7 @@ static bool create_pcb(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol) esp_err_t _mdns_pcb_init(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol) { - ESP_LOGI(TAG, "_mdns_pcb_init(tcpip_if=%d, ip_protocol=%d)", tcpip_if, ip_protocol); + ESP_LOGI(TAG, "_mdns_pcb_init(tcpip_if=%zu, ip_protocol=%d)", tcpip_if, ip_protocol); if (!create_pcb(tcpip_if, ip_protocol)) { return ESP_FAIL; } diff --git a/components/mdns/private_include/mdns_private.h b/components/mdns/private_include/mdns_private.h index 939a0632926..627d42c3e1d 100644 --- a/components/mdns/private_include/mdns_private.h +++ b/components/mdns/private_include/mdns_private.h @@ -159,7 +159,7 @@ #define PCB_STATE_IS_RUNNING(s) (s->state == PCB_RUNNING) #ifndef HOOK_MALLOC_FAILED -#define HOOK_MALLOC_FAILED ESP_LOGE(TAG, "Cannot allocate memory (line: %d, free heap: %d bytes)", __LINE__, esp_get_free_heap_size()); +#define HOOK_MALLOC_FAILED ESP_LOGE(TAG, "Cannot allocate memory (line: %d, free heap: %" PRIu32 " bytes)", __LINE__, esp_get_free_heap_size()); #endif typedef size_t mdns_if_t; diff --git a/components/mdns/tests/test_apps/main/CMakeLists.txt b/components/mdns/tests/test_apps/main/CMakeLists.txt index 45b06ffa339..b5902d5891c 100644 --- a/components/mdns/tests/test_apps/main/CMakeLists.txt +++ b/components/mdns/tests/test_apps/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "main.c" "mdns_test.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/mdns/tests/test_apps/main/main.c b/components/mdns/tests/test_apps/main/main.c index 9fc136b6163..e67014ce44c 100644 --- a/components/mdns/tests/test_apps/main/main.c +++ b/components/mdns/tests/test_apps/main/main.c @@ -92,7 +92,7 @@ static void initialise_mdns(void) void app_main(void) { - 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_ERROR_CHECK(nvs_flash_init());