From def2034d073f81a2c832da212ea352e8057bdd35 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 8 Nov 2025 23:43:29 +0000 Subject: [PATCH] Fix printf format specifiers for uint64_t and uint32_t Use PRIu64 and PRIu32 macros from inttypes.h instead of %llu and %u to fix compilation errors with newer ESP-IDF versions --- main/iperf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main/iperf.c b/main/iperf.c index ba2b988..cdd7552 100644 --- a/main/iperf.c +++ b/main/iperf.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -110,7 +111,7 @@ static esp_err_t iperf_start_tcp_server(iperf_ctrl_t *ctrl) total_len += recv_len; } - ESP_LOGI(TAG, "TCP server received: %llu bytes", total_len); + ESP_LOGI(TAG, "TCP server received: %" PRIu64 " bytes", total_len); close(client_sock); } @@ -154,7 +155,7 @@ static esp_err_t iperf_start_tcp_client(iperf_ctrl_t *ctrl) uint32_t actual_time = (xTaskGetTickCount() - start_time) / configTICK_RATE_HZ; float bandwidth = (float)total_len * 8 / actual_time / 1000000; // Mbps - ESP_LOGI(TAG, "TCP client sent: %llu bytes in %u seconds (%.2f Mbps)", + ESP_LOGI(TAG, "TCP client sent: %" PRIu64 " bytes in %" PRIu32 " seconds (%.2f Mbps)", total_len, actual_time, bandwidth); close(sockfd); @@ -215,7 +216,7 @@ static esp_err_t iperf_start_udp_server(iperf_ctrl_t *ctrl) } float loss_rate = packet_count > 0 ? (float)lost_packets * 100 / packet_count : 0; - ESP_LOGI(TAG, "UDP server received: %llu bytes, %u packets, %u lost (%.2f%%)", + ESP_LOGI(TAG, "UDP server received: %" PRIu64 " bytes, %" PRIu32 " packets, %" PRIu32 " lost (%.2f%%)", total_len, packet_count, lost_packets, loss_rate); close(sockfd); @@ -264,7 +265,7 @@ static esp_err_t iperf_start_udp_client(iperf_ctrl_t *ctrl) uint32_t actual_time = (xTaskGetTickCount() - start_time) / configTICK_RATE_HZ; float bandwidth = actual_time > 0 ? (float)total_len * 8 / actual_time / 1000000 : 0; - ESP_LOGI(TAG, "UDP client sent: %llu bytes, %u packets in %u seconds (%.2f Mbps)", + ESP_LOGI(TAG, "UDP client sent: %" PRIu64 " bytes, %" PRIu32 " packets in %" PRIu32 " seconds (%.2f Mbps)", total_len, packet_count, actual_time, bandwidth); close(sockfd);