Skip to content

Commit

Permalink
fix warnings (#211)
Browse files Browse the repository at this point in the history
* fix warnings

* fix warnings
  • Loading branch information
jthomas43 authored Oct 5, 2024
1 parent 5bbe628 commit be1991b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 22 deletions.
5 changes: 3 additions & 2 deletions examples/client.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions examples/udxperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -526,8 +526,7 @@ typedef enum {
SW_C,
SW_T,
SW_I,
SW_P,
SW_X,
SW_P
} switch_type_t;

int
Expand Down
1 change: 1 addition & 0 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include "queue.h"
#include <inttypes.h>

#ifdef DEBUG_STATS
#include "../include/udx.h"
Expand Down
1 change: 1 addition & 0 deletions src/io_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

int
udx__get_link_mtu (const struct sockaddr *addr) {
UDX_UNUSED(addr);
return -1;
}

Expand Down
5 changes: 2 additions & 3 deletions src/udx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/stream-change-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/stream-multiple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/stream-relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
17 changes: 9 additions & 8 deletions test/stream-write-read-perf.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -121,17 +122,17 @@ 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);

assert(data != NULL && "malloc");

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);
Expand All @@ -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;
}

0 comments on commit be1991b

Please sign in to comment.