From 4fe022d22e3d04bae4aa7e35d37a7beda4241f6c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 10 Jun 2024 18:52:00 -0700 Subject: [PATCH 1/2] fix more formats Signed-off-by: Rosen Penev --- src/iperf_api.c | 4 ++-- src/iperf_locale.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 4c73e8328..14056de36 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -3554,7 +3554,7 @@ iperf_print_intermediate(struct iperf_test *test) iperf_size_t bytes = 0; double bandwidth; - int retransmits = 0; + int64_t retransmits = 0; double start_time, end_time; int64_t total_packets = 0, lost_packets = 0; @@ -3630,7 +3630,7 @@ iperf_print_intermediate(struct iperf_test *test) if (test->sender_has_retransmits == 1 && stream_must_be_sender) { /* Interval sum, TCP with retransmits. */ if (test->json_output) - cJSON_AddItemToObject(json_interval, sum_name, iperf_json_printf("start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d omitted: %b sender: %b", (double) start_time, (double) end_time, (double) irp->interval_duration, (int64_t) bytes, bandwidth * 8, (int64_t) retransmits, irp->omitted, stream_must_be_sender)); /* XXX irp->omitted or test->omitting? */ + cJSON_AddItemToObject(json_interval, sum_name, iperf_json_printf("start: %f end: %f seconds: %f bytes: %d bits_per_second: %f retransmits: %d omitted: %b sender: %b", (double) start_time, (double) end_time, (double) irp->interval_duration, (int64_t) bytes, bandwidth * 8, retransmits, irp->omitted, stream_must_be_sender)); /* XXX irp->omitted or test->omitting? */ else iperf_printf(test, report_sum_bw_retrans_format, mbuf, start_time, end_time, ubuf, nbuf, retransmits, irp->omitted?report_omitted:""); /* XXX irp->omitted or test->omitting? */ } else { diff --git a/src/iperf_locale.c b/src/iperf_locale.c index 9d94e0234..64940108a 100644 --- a/src/iperf_locale.c +++ b/src/iperf_locale.c @@ -292,10 +292,10 @@ const char test_start_time[] = "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d second test, tos %d\n"; const char test_start_bytes[] = -"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %llu bytes to send, tos %d\n"; +"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %"PRIuFAST64" bytes to send, tos %d\n"; const char test_start_blocks[] = -"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %d blocks to send, tos %d\n"; +"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %"PRIuFAST64" bytes to send, tos %d\n"; /* ------------------------------------------------------------------- @@ -381,10 +381,10 @@ const char report_bw_format[] = "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %s\n"; const char report_bw_retrans_format[] = -"[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %3u %s\n"; +"[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %3ld %s\n"; const char report_bw_retrans_cwnd_format[] = -"[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %3u %ss %s\n"; +"[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %3ld %ss %s\n"; const char report_bw_udp_format[] = "[%3d]%s %6.2f-%-6.2f sec %ss %ss/sec %5.3f ms %" PRId64 "/%" PRId64 " (%.2g%%) %s\n"; @@ -402,7 +402,7 @@ const char report_sum_bw_format[] = "[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %s\n"; const char report_sum_bw_retrans_format[] = -"[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %3d %s\n"; +"[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %3"PRId64" %s\n"; const char report_sum_bw_udp_format[] = "[SUM]%s %6.2f-%-6.2f sec %ss %ss/sec %5.3f ms %" PRId64 "/%" PRId64 " (%.2g%%) %s\n"; @@ -419,7 +419,7 @@ const char report_outoforder[] = "[%3d]%s %4.1f-%4.1f sec %d datagrams received out-of-order\n"; const char report_sum_outoforder[] = -"[SUM]%s %4.1f-%4.1f sec %d datagrams received out-of-order\n"; +"[SUM]%s %4.1f-%4.1f sec %"PRIu64" datagrams received out-of-order\n"; const char report_peer[] = "[%3d] local %s port %u connected with %s port %u\n"; From d976d43065de28d3f62403c60af11839c616f6c0 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 10 Jun 2024 20:50:47 -0700 Subject: [PATCH 2/2] cast time_t to 64-bit time_t is 64-bit, even under 32-bit musl. Cast to 64-bit to make it compatible everywhere. Signed-off-by: Rosen Penev --- src/iperf_api.c | 4 ++-- src/iperf_locale.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 14056de36..4653adbc5 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -2081,14 +2081,14 @@ int test_is_authorized(struct iperf_test *test){ int ret = check_authentication(username, password, ts, test->server_authorized_users, test->server_skew_threshold); if (ret == 0){ if (test->debug) { - iperf_printf(test, report_authentication_succeeded, username, ts); + iperf_printf(test, report_authentication_succeeded, username, (uint64_t)ts); } free(username); free(password); return 0; } else { if (test->debug) { - iperf_printf(test, report_authentication_failed, ret, username, ts); + iperf_printf(test, report_authentication_failed, ret, username, (uint64_t)ts); } free(username); free(password); diff --git a/src/iperf_locale.c b/src/iperf_locale.c index 64940108a..cfdba5826 100644 --- a/src/iperf_locale.c +++ b/src/iperf_locale.c @@ -309,10 +309,10 @@ const char report_connecting[] = "Connecting to host %s, port %d\n"; const char report_authentication_succeeded[] = -"Authentication succeeded for user '%s' ts %ld\n"; +"Authentication succeeded for user '%s' ts %" PRIu64 "\n"; const char report_authentication_failed[] = -"Authentication failed with return code %d for user '%s' ts %ld\n"; +"Authentication failed with return code %d for user '%s' ts %" PRIu64 "\n"; const char report_reverse[] = "Reverse mode, remote host %s is sending\n";