diff --git a/examples/common_components/iperf/CMakeLists.txt b/examples/common_components/iperf/CMakeLists.txt index 3662ec032a..85a30c1257 100644 --- a/examples/common_components/iperf/CMakeLists.txt +++ b/examples/common_components/iperf/CMakeLists.txt @@ -6,8 +6,6 @@ idf_component_register(SRCS "iperf.c" REQUIRES lwip PRIV_REQUIRES esp_timer) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") - if(CONFIG_SOC_WIFI_HE_SUPPORT) idf_component_optional_requires(PRIVATE esp_wifi console) endif() diff --git a/examples/common_components/iperf/iperf.c b/examples/common_components/iperf/iperf.c index d2adf83276..ced73a1f02 100644 --- a/examples/common_components/iperf/iperf.c +++ b/examples/common_components/iperf/iperf.c @@ -1,7 +1,7 @@ /* Iperf Example - iperf implementation This example code is in the Public Domain (or CC0 licensed, at your option.) - +/ Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -11,6 +11,7 @@ #include #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_check.h" @@ -86,14 +87,14 @@ static void iperf_report_task(void *arg) while (!s_iperf_ctrl.finish) { vTaskDelay(delay_interval); actual_bandwidth = (s_iperf_ctrl.actual_len / coefficient[format] * 8) / interval; - printf("%4d-%4d sec %.2f %cbits/sec\n", cur, cur + interval, + printf("%4" PRIi32 "-%4" PRIi32 " sec %.2f %cbits/sec\n", cur, cur + interval, actual_bandwidth, unit[format]); cur += interval; average = ((average * (k - 1) / k) + (actual_bandwidth / k)); k++; s_iperf_ctrl.actual_len = 0; if (cur >= time) { - printf("%4d-%4d sec %.2f %cbits/sec\n", 0, time, + printf("%4d-%4" PRIu32 " sec %.2f %cbits/sec\n", 0, time, average, unit[format]); break; } @@ -395,7 +396,7 @@ static esp_err_t IRAM_ATTR iperf_run_udp_server(void) err = bind(listen_socket, (struct sockaddr *)&listen_addr6, sizeof(struct sockaddr_in6)); ESP_GOTO_ON_FALSE((err == 0), ESP_FAIL, exit, TAG, "Socket unable to bind: errno %d", errno); - ESP_LOGI(TAG, "Socket bound, port %d", listen_addr6.sin6_port); + ESP_LOGI(TAG, "Socket bound, port %" PRIu16, listen_addr6.sin6_port); memcpy(&listen_addr, &listen_addr6, sizeof(listen_addr6)); } else if (s_iperf_ctrl.cfg.type == IPERF_IP_TYPE_IPV4) { @@ -452,7 +453,7 @@ static esp_err_t iperf_run_udp_client(void) client_socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IPV6); ESP_GOTO_ON_FALSE((client_socket >= 0), ESP_FAIL, exit, TAG, "Unable to create socket: errno %d", errno); - ESP_LOGI(TAG, "Socket created, sending to %s:%d", s_iperf_ctrl.cfg.destination_ip6, s_iperf_ctrl.cfg.dport); + ESP_LOGI(TAG, "Socket created, sending to %s:%" PRIu16, s_iperf_ctrl.cfg.destination_ip6, s_iperf_ctrl.cfg.dport); setsockopt(client_socket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); memcpy(&dest_addr, &dest_addr6, sizeof(dest_addr6)); @@ -463,7 +464,12 @@ static esp_err_t iperf_run_udp_client(void) client_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); ESP_GOTO_ON_FALSE((client_socket >= 0), ESP_FAIL, exit, TAG, "Unable to create socket: errno %d", errno); - ESP_LOGI(TAG, "Socket created, sending to %d:%d", s_iperf_ctrl.cfg.destination_ip4, s_iperf_ctrl.cfg.dport); + ESP_LOGI(TAG, "Socket created, sending to %d.%d.%d.%d:%" PRIu16, + (uint16_t) s_iperf_ctrl.cfg.destination_ip4 & 0xFF, + (uint16_t) (s_iperf_ctrl.cfg.destination_ip4 >> 8) & 0xFF, + (uint16_t) (s_iperf_ctrl.cfg.destination_ip4 >> 16) & 0xFF, + (uint16_t) (s_iperf_ctrl.cfg.destination_ip4 >> 24) & 0xFF, + s_iperf_ctrl.cfg.dport); setsockopt(client_socket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); memcpy(&dest_addr, &dest_addr4, sizeof(dest_addr4)); diff --git a/examples/ethernet/iperf/main/CMakeLists.txt b/examples/ethernet/iperf/main/CMakeLists.txt index 0efe55ab10..fc8e5dd8bb 100644 --- a/examples/ethernet/iperf/main/CMakeLists.txt +++ b/examples/ethernet/iperf/main/CMakeLists.txt @@ -1,4 +1,3 @@ idf_component_register(SRCS "cmd_ethernet.c" "ethernet_example_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/ethernet/iperf/main/cmd_ethernet.c b/examples/ethernet/iperf/main/cmd_ethernet.c index 0a7754feea..cb4158af02 100644 --- a/examples/ethernet/iperf/main/cmd_ethernet.c +++ b/examples/ethernet/iperf/main/cmd_ethernet.c @@ -8,6 +8,7 @@ */ #include #include +#include #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" #include "sys/socket.h" // for INADDR_ANY @@ -175,11 +176,14 @@ static int eth_cmd_iperf(int argc, char **argv) } } - printf("mode=%s-%s sip=%d.%d.%d.%d:%d, dip=%d.%d.%d.%d:%d, interval=%d, time=%d\r\n", + printf("mode=%s-%s sip=" IPSTR ":%" PRIu16 ", dip=%" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 ":%" PRIu16 ", interval=%" PRIu32 ", time=%" PRIu32 "\r\n", cfg.flag & IPERF_FLAG_TCP ? "tcp" : "udp", cfg.flag & IPERF_FLAG_SERVER ? "server" : "client", - cfg.source_ip4 & 0xFF, (cfg.source_ip4 >> 8) & 0xFF, (cfg.source_ip4 >> 16) & 0xFF, - (cfg.source_ip4 >> 24) & 0xFF, cfg.sport, + (uint16_t) cfg.source_ip4 & 0xFF, + (uint16_t) (cfg.source_ip4 >> 8) & 0xFF, + (uint16_t) (cfg.source_ip4 >> 16) & 0xFF, + (uint16_t) (cfg.source_ip4 >> 24) & 0xFF, + cfg.sport, cfg.destination_ip4 & 0xFF, (cfg.destination_ip4 >> 8) & 0xFF, (cfg.destination_ip4 >> 16) & 0xFF, (cfg.destination_ip4 >> 24) & 0xFF, cfg.dport, cfg.interval, cfg.time); diff --git a/examples/network/simple_sniffer/main/CMakeLists.txt b/examples/network/simple_sniffer/main/CMakeLists.txt index 485037a752..5d4205471d 100644 --- a/examples/network/simple_sniffer/main/CMakeLists.txt +++ b/examples/network/simple_sniffer/main/CMakeLists.txt @@ -2,4 +2,3 @@ idf_component_register(SRCS "simple_sniffer_example_main.c" "cmd_sniffer.c" "cmd_pcap.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/network/simple_sniffer/main/cmd_sniffer.c b/examples/network/simple_sniffer/main/cmd_sniffer.c index 31b1aad800..aae307df62 100644 --- a/examples/network/simple_sniffer/main/cmd_sniffer.c +++ b/examples/network/simple_sniffer/main/cmd_sniffer.c @@ -430,7 +430,7 @@ static int do_sniffer_cmd(int argc, char **argv) snf_rt.packets_to_sniff = -1; if (sniffer_args.number->count) { snf_rt.packets_to_sniff = sniffer_args.number->ival[0]; - ESP_LOGI(SNIFFER_TAG, "%d packages will be captured", snf_rt.packets_to_sniff); + ESP_LOGI(SNIFFER_TAG, "%" PRIi32 " packages will be captured", snf_rt.packets_to_sniff); } /* start sniffer */ diff --git a/examples/protocols/icmp_echo/main/CMakeLists.txt b/examples/protocols/icmp_echo/main/CMakeLists.txt index 7797d714dd..30b73c7688 100644 --- a/examples/protocols/icmp_echo/main/CMakeLists.txt +++ b/examples/protocols/icmp_echo/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "echo_example_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/icmp_echo/main/echo_example_main.c b/examples/protocols/icmp_echo/main/echo_example_main.c index ce7955b7fd..18a3b148b8 100644 --- a/examples/protocols/icmp_echo/main/echo_example_main.c +++ b/examples/protocols/icmp_echo/main/echo_example_main.c @@ -31,7 +31,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)); - printf("%d bytes from %s icmp_seq=%d ttl=%d time=%d ms\n", + printf("%" PRIu32 " bytes from %s icmp_seq=%" PRIu16 " ttl=%" PRIu16 " time=%" PRIu32 " ms\n", recv_len, ipaddr_ntoa((ip_addr_t*)&target_addr), seqno, ttl, elapsed_time); } @@ -60,7 +60,7 @@ static void cmd_ping_on_ping_end(esp_ping_handle_t hdl, void *args) } else { printf("\n--- %s ping statistics ---\n", inet6_ntoa(*ip_2_ip6(&target_addr))); } - printf("%d packets transmitted, %d received, %d%% packet loss, time %dms\n", + printf("%" 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/examples/protocols/mqtt/ssl/main/CMakeLists.txt b/examples/protocols/mqtt/ssl/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ssl/main/app_main.c b/examples/protocols/mqtt/ssl/main/app_main.c index acfcb3f745..570bdd3fec 100644 --- a/examples/protocols/mqtt/ssl/main/app_main.c +++ b/examples/protocols/mqtt/ssl/main/app_main.c @@ -62,7 +62,7 @@ static void send_binary(esp_mqtt_client_handle_t client) */ 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=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -130,7 +130,7 @@ static void mqtt_app_start(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_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -140,7 +140,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt index c31750a8f7..b8ef6eadbd 100644 --- a/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_ds/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "app_main.c" - INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") + INCLUDE_DIRS "." + REQUIRED_IDF_TARGETS esp32s2 esp32c3 esp32s3) diff --git a/examples/protocols/mqtt/ssl_ds/main/app_main.c b/examples/protocols/mqtt/ssl_ds/main/app_main.c index 709143c6c3..160392a4e4 100644 --- a/examples/protocols/mqtt/ssl_ds/main/app_main.c +++ b/examples/protocols/mqtt/ssl_ds/main/app_main.c @@ -47,7 +47,7 @@ extern const uint8_t server_cert_pem_end[] asm("_binary_mosquitto_org_crt_end"); */ 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=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -124,7 +124,7 @@ static void mqtt_app_start(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_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); esp_mqtt_client_start(client); @@ -133,7 +133,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_mutual_auth/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c b/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c index 76cc45563a..9798cb9b49 100644 --- a/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c +++ b/examples/protocols/mqtt/ssl_mutual_auth/main/app_main.c @@ -57,7 +57,7 @@ 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_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -122,7 +122,7 @@ static void mqtt_app_start(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_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -132,7 +132,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt b/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ssl_psk/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ssl_psk/main/app_main.c b/examples/protocols/mqtt/ssl_psk/main/app_main.c index f024e1382a..67df8639b2 100644 --- a/examples/protocols/mqtt/ssl_psk/main/app_main.c +++ b/examples/protocols/mqtt/ssl_psk/main/app_main.c @@ -64,7 +64,7 @@ static const psk_hint_key_t psk_hint_key = { */ 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=%" PRIi32 "", base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -117,7 +117,7 @@ static void mqtt_app_start(void) .broker.verification.psk_hint_key = &psk_hint_key, }; - 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_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -127,7 +127,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt/tcp/main/CMakeLists.txt b/examples/protocols/mqtt/tcp/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/tcp/main/CMakeLists.txt +++ b/examples/protocols/mqtt/tcp/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/tcp/main/app_main.c b/examples/protocols/mqtt/tcp/main/app_main.c index f40581296b..06ff1ad43e 100644 --- a/examples/protocols/mqtt/tcp/main/app_main.c +++ b/examples/protocols/mqtt/tcp/main/app_main.c @@ -52,7 +52,7 @@ 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_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -146,7 +146,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt/ws/main/CMakeLists.txt b/examples/protocols/mqtt/ws/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/ws/main/CMakeLists.txt +++ b/examples/protocols/mqtt/ws/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/ws/main/app_main.c b/examples/protocols/mqtt/ws/main/app_main.c index 247f305184..59f09cf4e0 100644 --- a/examples/protocols/mqtt/ws/main/app_main.c +++ b/examples/protocols/mqtt/ws/main/app_main.c @@ -50,7 +50,7 @@ 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_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; @@ -119,7 +119,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt/wss/main/CMakeLists.txt b/examples/protocols/mqtt/wss/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt/wss/main/CMakeLists.txt +++ b/examples/protocols/mqtt/wss/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt/wss/main/app_main.c b/examples/protocols/mqtt/wss/main/app_main.c index 0e570b11be..f91305180e 100644 --- a/examples/protocols/mqtt/wss/main/app_main.c +++ b/examples/protocols/mqtt/wss/main/app_main.c @@ -89,7 +89,7 @@ static esp_err_t mqtt_event_handler_cb(esp_mqtt_event_handle_t event) static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { /* The argument passed to esp_mqtt_client_register_event can de accessed as handler_args*/ - 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=%" PRIi32, base, event_id); mqtt_event_handler_cb(event_data); } @@ -100,7 +100,7 @@ static void mqtt_app_start(void) .broker.verification.certificate = (const char *)mqtt_eclipseprojects_io_pem_start, }; - 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_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg); /* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */ esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL); @@ -111,7 +111,7 @@ static void mqtt_app_start(void) 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/examples/protocols/mqtt5/main/CMakeLists.txt b/examples/protocols/mqtt5/main/CMakeLists.txt index c31750a8f7..61fac40e63 100644 --- a/examples/protocols/mqtt5/main/CMakeLists.txt +++ b/examples/protocols/mqtt5/main/CMakeLists.txt @@ -1,3 +1,2 @@ idf_component_register(SRCS "app_main.c" INCLUDE_DIRS ".") -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/examples/protocols/mqtt5/main/app_main.c b/examples/protocols/mqtt5/main/app_main.c index a0f7ee8a0b..461ca4c2d7 100644 --- a/examples/protocols/mqtt5/main/app_main.c +++ b/examples/protocols/mqtt5/main/app_main.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: Apache-2.0 */ @@ -99,12 +99,12 @@ static void print_user_property(mqtt5_user_property_handle_t user_property) */ static void mqtt5_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=%" PRIi32, base, event_id); esp_mqtt_event_handle_t event = event_data; esp_mqtt_client_handle_t client = event->client; int msg_id; - ESP_LOGD(TAG, "free heap size is %d, maxminu %d", esp_get_free_heap_size(), esp_get_minimum_free_heap_size()); + ESP_LOGD(TAG, "free heap size is %" PRIu32 ", minimum %" PRIu32, esp_get_free_heap_size(), esp_get_minimum_free_heap_size()); switch ((esp_mqtt_event_id_t)event_id) { case MQTT_EVENT_CONNECTED: ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED"); @@ -263,8 +263,9 @@ static void mqtt5_app_start(void) 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);