From be1991bee85ad4f51f0ea939700e243992828ec6 Mon Sep 17 00:00:00 2001 From: jthomas43 <129407891+jthomas43@users.noreply.github.com> Date: Sat, 5 Oct 2024 03:22:30 -0400 Subject: [PATCH] fix warnings (#211) * fix warnings * fix warnings --- examples/client.c | 5 +++-- examples/udxperf.c | 5 ++--- src/debug.h | 1 + src/io_posix.c | 1 + src/udx.c | 5 ++--- test/stream-change-remote.c | 4 ++-- test/stream-multiple.c | 4 ++-- test/stream-relay.c | 4 ++-- test/stream-write-read-perf.c | 17 +++++++++-------- 9 files changed, 24 insertions(+), 22 deletions(-) diff --git a/examples/client.c b/examples/client.c index d9afebde..dd101f2f 100644 --- a/examples/client.c +++ b/examples/client.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -33,7 +34,7 @@ get_milliseconds () { static void on_uv_interval (uv_timer_t *handle) { - printf("received %zu bytes in %lu ms\n", bytes_recv, get_milliseconds() - started); + printf("received %zu bytes in %" PRIu64 " ms\n", bytes_recv, get_milliseconds() - started); } static void @@ -45,7 +46,7 @@ on_read (udx_stream_t *handle, ssize_t read_len, const uv_buf_t *buf) { } if (read_len < 0) { - printf("received %zu bytes in %lu ms\n", bytes_recv, get_milliseconds() - started); + printf("received %zu bytes in %" PRIu64 " ms\n", bytes_recv, get_milliseconds() - started); printf("stream is done!\n"); exit(0); } diff --git a/examples/udxperf.c b/examples/udxperf.c index f38c5162..5ff6811b 100644 --- a/examples/udxperf.c +++ b/examples/udxperf.c @@ -391,7 +391,7 @@ on_ack (udx_stream_write_t *req, int status, int unordered) { static void pump_writes (udx_stream_t *stream) { - uv_buf_t chunk = uv_buf_init(chunk_bytes, sizeof(chunk_bytes)); + uv_buf_t chunk = uv_buf_init((char *) chunk_bytes, sizeof(chunk_bytes)); while (1) { udx_stream_write_t *req = malloc(udx_stream_write_sizeof(1)); @@ -526,8 +526,7 @@ typedef enum { SW_C, SW_T, SW_I, - SW_P, - SW_X, + SW_P } switch_type_t; int diff --git a/src/debug.h b/src/debug.h index 4609aab3..df61ec1d 100644 --- a/src/debug.h +++ b/src/debug.h @@ -8,6 +8,7 @@ #endif #include "queue.h" +#include #ifdef DEBUG_STATS #include "../include/udx.h" diff --git a/src/io_posix.c b/src/io_posix.c index aecd17ad..59860ac5 100644 --- a/src/io_posix.c +++ b/src/io_posix.c @@ -19,6 +19,7 @@ int udx__get_link_mtu (const struct sockaddr *addr) { + UDX_UNUSED(addr); return -1; } diff --git a/src/udx.c b/src/udx.c index 4ee82e48..d960b1e2 100644 --- a/src/udx.c +++ b/src/udx.c @@ -846,7 +846,7 @@ udx_rto_timeout (uv_timer_t *timer) { // zero retransmit queue udx__queue_init(&stream->retransmit_queue); - debug_printf("rto: lost rid=%u [%u:%u] inflight=%lu ssthresh=%u cwnd=%u srtt=%u\n", stream->remote_id, stream->remote_acked, stream->seq, stream->inflight, stream->ssthresh, stream->cwnd, stream->srtt); + debug_printf("rto: lost rid=%u [%u:%u] inflight=%zu ssthresh=%u cwnd=%u srtt=%u\n", stream->remote_id, stream->remote_acked, stream->seq, stream->inflight, stream->ssthresh, stream->cwnd, stream->srtt); uint64_t now = uv_now(timer->loop); uint32_t rack_reo_wnd = rack_update_reo_wnd(stream); @@ -935,7 +935,7 @@ clamp_rtt (udx_stream_t *stream, uint64_t rtt) { const uint32_t outlier_threshold = stream->srtt + 5 * stream->rttvar; if (rtt > outlier_threshold && rtt > 5000) { rtt = min_uint32(outlier_threshold, UDX_RTT_MAX_MS); - debug_printf("rtt: clamp rtt for stream=%u to rtt=%lu\n", stream->remote_id, rtt); + debug_printf("rtt: clamp rtt for stream=%u to rtt=%" PRIu64 "\n", stream->remote_id, rtt); } return rtt; @@ -1056,7 +1056,6 @@ ack_packet (udx_stream_t *stream, uint32_t seq, int sack) { free(pkt); - // debug_printf("pkt_len=%lu write->bytes_acked=%lu write->size=%lu\n", pkt_len, writewrite>bytes_acked, write->buf.len); if (stream->status & UDX_STREAM_DEAD) return 2; // reentry from write->on_ack // TODO: the end condition needs work here to be more "stateless" diff --git a/test/stream-change-remote.c b/test/stream-change-remote.c index efc0c7fe..8387d35a 100644 --- a/test/stream-change-remote.c +++ b/test/stream-change-remote.c @@ -66,7 +66,7 @@ on_read (udx_stream_t *handle, ssize_t read_len, const uv_buf_t *buf) { nbytes_read += read_len; - read_hash = hash(read_hash, buf->base, read_len); + read_hash = hash(read_hash, (uint8_t *) buf->base, read_len); // swap to relay 1/3 of the way into the stream @@ -159,7 +159,7 @@ main () { uv_buf_t buf = uv_buf_init(malloc(NBYTES_TO_SEND), NBYTES_TO_SEND); - write_hash = hash(write_hash, buf.base, buf.len); + write_hash = hash(write_hash, (uint8_t *) buf.base, buf.len); e = udx_stream_write(req, &dstream, &buf, 1, on_ack); assert(e == 0); // write bigger than hwm diff --git a/test/stream-multiple.c b/test/stream-multiple.c index f1a8f11f..effd4017 100644 --- a/test/stream-multiple.c +++ b/test/stream-multiple.c @@ -58,7 +58,7 @@ on_read (udx_stream_t *handle, ssize_t read_len, const uv_buf_t *buf) { struct receiver *r = &receiver[handle->local_id - NSTREAMS]; r->nbytes_read += read_len; - r->read_hash = hash(r->read_hash, buf->base, read_len); + r->read_hash = hash(r->read_hash, (uint8_t *) buf->base, read_len); } int @@ -74,7 +74,7 @@ main () { size_t write_hash = HASH_INIT; - write_hash = hash(write_hash, buf.base, buf.len); + write_hash = hash(write_hash, (uint8_t *) buf.base, buf.len); for (int i = 0; i < NSTREAMS; i++) { int sender_id = i; diff --git a/test/stream-relay.c b/test/stream-relay.c index 0fcc8377..4d3fc50c 100644 --- a/test/stream-relay.c +++ b/test/stream-relay.c @@ -53,7 +53,7 @@ on_read (udx_stream_t *handle, ssize_t read_len, const uv_buf_t *buf) { printf("read_len=%ld\n", read_len); assert(memcmp(buf->base, "hello", 5) == 0); } - read_hash = hash(read_hash, buf->base, read_len); + read_hash = hash(read_hash, (uint8_t *) buf->base, read_len); nbytes_read += read_len; read_called = true; @@ -135,7 +135,7 @@ main () { memcpy(buf.base, "hello", 5); - write_hash = hash(write_hash, buf.base, buf.len); + write_hash = hash(write_hash, (uint8_t *) buf.base, buf.len); udx_stream_write(req, &dstream, &buf, 1, on_ack); diff --git a/test/stream-write-read-perf.c b/test/stream-write-read-perf.c index 2ba264aa..f55e0009 100644 --- a/test/stream-write-read-perf.c +++ b/test/stream-write-read-perf.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -47,7 +48,7 @@ on_read (udx_stream_t *handle, ssize_t read_len, const uv_buf_t *buf) { assert(read_len == buf->len); - read_hash = hash(read_hash, buf->base, read_len); + read_hash = hash(read_hash, (uint8_t *) buf->base, read_len); if (stats.bytes_read == options.size_bytes) { printf("read all bytes\n"); @@ -121,9 +122,9 @@ main () { assert(e == 0); options.size_bytes = 500 * 1024 * 1024L; - printf("generating data ... (%lu bytes)\n", options.size_bytes); + printf("generating data ... (%" PRIu64 " bytes)\n", options.size_bytes); - char *data = calloc(options.size_bytes, 1); + uint8_t *data = calloc(options.size_bytes, 1); write_hash = hash(write_hash, data, options.size_bytes); @@ -131,7 +132,7 @@ main () { printf("writing data\n"); - uv_buf_t buf = uv_buf_init(data, options.size_bytes); + uv_buf_t buf = uv_buf_init((char *) data, options.size_bytes); udx_stream_write(req, &bstream, &buf, 1, on_ack); e = uv_run(&loop, UV_RUN_DEFAULT); @@ -141,12 +142,12 @@ main () { free(data); // valgrind free(req); // valgrind - printf("readhash=%lx writehash=%lx\n", read_hash, write_hash); + printf("readhash=%" PRIx64 " writehash=%" PRIx64 "\n", read_hash, write_hash); assert(read_hash == write_hash); - printf("stats: udx: bytes_rx=%lu packets_rx=%lu bytes_tx=%lu packets_tx=%lu\n", udx.bytes_rx, udx.packets_rx, udx.bytes_tx, udx.packets_tx); - printf("stats: stream a: bytes_rx=%lu packets_rx=%lu bytes_tx=%lu packets_tx=%lu\n", astream.bytes_rx, astream.packets_rx, astream.bytes_tx, astream.packets_tx); - printf("stats: stream b: bytes_rx=%lu packets_rx=%lu bytes_tx=%lu packets_tx=%lu\n", bstream.bytes_rx, bstream.packets_rx, bstream.bytes_tx, bstream.packets_tx); + printf("stats: udx: bytes_rx=%" PRIu64 " packets_rx=%" PRIu64 " bytes_tx=%" PRIu64 " packets_tx=%" PRIu64 "\n", udx.bytes_rx, udx.packets_rx, udx.bytes_tx, udx.packets_tx); + printf("stats: stream a: bytes_rx=%" PRIu64 " packets_rx=%" PRIu64 " bytes_tx=%" PRIu64 " packets_tx=%" PRIu64 "\n", astream.bytes_rx, astream.packets_rx, astream.bytes_tx, astream.packets_tx); + printf("stats: stream b: bytes_rx=%" PRIu64 " packets_rx=%" PRIu64 " bytes_tx=%" PRIu64 " packets_tx=%" PRIu64 "\n", bstream.bytes_rx, bstream.packets_rx, bstream.bytes_tx, bstream.packets_tx); return 0; }