From 069e5118218d6eca7da415de67395848fe970514 Mon Sep 17 00:00:00 2001 From: Paul Nowoczynski Date: Fri, 31 May 2024 19:02:26 -0400 Subject: [PATCH] Fixed unused and signedness in tests/ --- test/binary-hist-test.c | 4 ++-- test/bitmap-test.c | 12 ++++++------ test/buffer-test.c | 4 ++-- test/common-test.c | 4 ++-- test/epoll-mgr-test.c | 5 +++++ test/ev-pipe-test.c | 1 + test/queue-test.c | 4 ++-- test/raft-net-test.c | 2 +- test/tcp-test.c | 2 +- test/udp-test.c | 2 +- test/work-dispatch-test.c | 2 +- 11 files changed, 24 insertions(+), 18 deletions(-) diff --git a/test/binary-hist-test.c b/test/binary-hist-test.c index a39eaaf9a..1cc4f03d5 100644 --- a/test/binary-hist-test.c +++ b/test/binary-hist-test.c @@ -41,14 +41,14 @@ dump_hist(const struct binary_hist *bh) } static void -fill_bh(int start_bit, int num_buckets) +fill_bh(unsigned int start_bit, unsigned int num_buckets) { struct binary_hist bh; NIOVA_ASSERT(!binary_hist_init(&bh, start_bit, num_buckets)); NIOVA_ASSERT(bh.bh_start_bit == start_bit); NIOVA_ASSERT(bh.bh_num_buckets == num_buckets); - NIOVA_ASSERT(binary_hist_size(&bh) == num_buckets); + NIOVA_ASSERT(binary_hist_size(&bh) == (int)num_buckets); for (int i = 0; i < binary_hist_size(&bh); i++) { diff --git a/test/bitmap-test.c b/test/bitmap-test.c index c495dfc6d..0458a243d 100644 --- a/test/bitmap-test.c +++ b/test/bitmap-test.c @@ -202,7 +202,7 @@ niova_bitmap_merge_test(void) rc = niova_bitmap_exclusive(&x, &y); FATAL_IF(rc, "niova_bitmap_exclusive(): %s", strerror(-rc)); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { x.nb_map[i] = 0xa55555555555555aULL; y.nb_map[i] = 0x5aaaaaaaaaaaaaa5ULL; @@ -254,7 +254,7 @@ niova_bitmap_bulk_unset_test(void) rc = niova_bitmap_shared(&y, &x); FATAL_IF(rc != -ENOENT, "niova_bitmap_shared(): %s", strerror(-rc)); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { x.nb_map[i] = -1ULL; y.nb_map[i] = 0x5555555555555555ULL; @@ -272,7 +272,7 @@ niova_bitmap_bulk_unset_test(void) rc = niova_bitmap_bulk_unset(&x, &y); FATAL_IF(rc, "niova_bitmap_unset(): %s", strerror(-rc)); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { niova_bitmap_init(&y); @@ -424,7 +424,7 @@ niova_bitmap_iterate_test(void) NIOVA_ASSERT(rc == 0); NIOVA_ASSERT(xarg.cnt == 0 && xarg.total_bits == 0); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) x_map[i] = -1ULL; rc = niova_bitmap_iterate(&x, niova_bitmap_iterate_cb, &xarg); @@ -435,7 +435,7 @@ niova_bitmap_iterate_test(void) xarg.cnt = 0; xarg.total_bits = 0; - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) x_map[i] = 0x1010101010101010; rc = niova_bitmap_iterate(&x, niova_bitmap_iterate_cb, &xarg); @@ -449,7 +449,7 @@ niova_bitmap_iterate_test(void) xarg.cnt = 0; xarg.total_bits = 0; - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) x_map[i] = 0x7070707070707070; rc = niova_bitmap_iterate(&x, niova_bitmap_iterate_cb, &xarg); diff --git a/test/buffer-test.c b/test/buffer-test.c index 4303caed9..ce810e10e 100644 --- a/test/buffer-test.c +++ b/test/buffer-test.c @@ -63,7 +63,7 @@ buffer_test(bool serialize, bool lreg) struct buffer_item *bi_array[n - 1]; - for (int i = 0; i < (n - 1); i++) + for (unsigned int i = 0; i < (n - 1); i++) { bi_array[i] = buffer_set_allocate_item_from_pending(&bs); NIOVA_ASSERT(bi_array[i]); @@ -74,7 +74,7 @@ buffer_test(bool serialize, bool lreg) rc = buffer_set_destroy(&bs); NIOVA_ASSERT(rc == -EBUSY); - for (int i = 0; i < (n - 1); i++) + for (unsigned int i = 0; i < (n - 1); i++) buffer_set_release_item(bi_array[i]); rc = buffer_set_destroy(&bs); diff --git a/test/common-test.c b/test/common-test.c index 9ade030c7..158032c14 100644 --- a/test/common-test.c +++ b/test/common-test.c @@ -13,7 +13,7 @@ highest_set_bit_pos_from_val_test(void) { NIOVA_ASSERT(highest_set_bit_pos_from_val(128) == 8); - for (int i = 0; i < TYPE_SZ_BITS(unsigned long long); i++) + for (unsigned int i = 0; i < TYPE_SZ_BITS(unsigned long long); i++) { const unsigned long long val = 1ULL << i; NIOVA_ASSERT(i + 1 == highest_set_bit_pos_from_val(val)); @@ -32,7 +32,7 @@ highest_set_bit_pos_from_val_test(void) static void highest_power_of_two_test(void) { - for (int i = 0; i < TYPE_SZ_BITS(unsigned long long); i++) + for (unsigned int i = 0; i < TYPE_SZ_BITS(unsigned long long); i++) { const unsigned long long val = 1ULL << i; diff --git a/test/epoll-mgr-test.c b/test/epoll-mgr-test.c index 47fe188ec..846f3fa16 100644 --- a/test/epoll-mgr-test.c +++ b/test/epoll-mgr-test.c @@ -52,6 +52,7 @@ static void foo_cb(const struct epoll_handle *eph, uint32_t events) { (void)eph; + (void)events; return; } @@ -84,6 +85,8 @@ epoll_mgr_thread_test_cb(const struct epoll_handle *eph, uint32_t events) { NIOVA_ASSERT(eph && eph->eph_arg); + (void)events; + struct epm_test_handle *eth = (struct epm_test_handle *)eph->eph_arg; // Sanity check @@ -484,6 +487,8 @@ epm_ctx_test_ref_cb(void *arg, enum epoll_handle_ref_op op) static void epoll_mgr_context_event_cb(const struct epoll_handle *_eph, uint32_t _ev) { + (void)_eph; + (void)_ev; FATAL_MSG("unexpected event received"); } diff --git a/test/ev-pipe-test.c b/test/ev-pipe-test.c index d8d444ff4..8f13edaba 100644 --- a/test/ev-pipe-test.c +++ b/test/ev-pipe-test.c @@ -48,6 +48,7 @@ ev_pipe_test_cb(const struct epoll_handle *eph, uint32_t events) EV_PIPE_RESET(evp); + (void)events; struct item *item = NULL, *tmp = NULL; size_t num_completed = 0; diff --git a/test/queue-test.c b/test/queue-test.c index b1162214f..ccca1d54a 100644 --- a/test/queue-test.c +++ b/test/queue-test.c @@ -33,7 +33,7 @@ circleq_splice_tail_test(void) // Basic head insert operation - int i; + unsigned int i; for (i = 0; i < NUM_CES; i++) { ce[i].ce_value = i; @@ -45,7 +45,7 @@ circleq_splice_tail_test(void) } // Foreach in both directions - int j = NUM_CES; + unsigned int j = NUM_CES; CIRCLEQ_FOREACH(tmp, &qx, ce_lentry) NIOVA_ASSERT(tmp->ce_value == --j); diff --git a/test/raft-net-test.c b/test/raft-net-test.c index adc613778..f63f3b3ac 100644 --- a/test/raft-net-test.c +++ b/test/raft-net-test.c @@ -46,7 +46,7 @@ vote_sort(void) rc = raft_server_get_majority_entry_idx(mix2, ARRAY_SIZE(mix2), &idx); NIOVA_ASSERT(!rc && idx == 127); - for (int i = 0; i < ARRAY_SIZE(mix2); i++) + for (unsigned int i = 0; i < ARRAY_SIZE(mix2); i++) { switch (i) { diff --git a/test/tcp-test.c b/test/tcp-test.c index c00db0b33..e8147577e 100644 --- a/test/tcp-test.c +++ b/test/tcp-test.c @@ -16,7 +16,7 @@ static niova_atomic64_t numPingPongsDone; #define DEFAULT_RUN_TIME 10; #define DEFAULT_TCP_SIZE 1024*1024; -static size_t tcpSize = DEFAULT_TCP_SIZE; +static ssize_t tcpSize = DEFAULT_TCP_SIZE; static size_t runTime = DEFAULT_RUN_TIME; /** diff --git a/test/udp-test.c b/test/udp-test.c index 9f42ec109..fa238bc7d 100644 --- a/test/udp-test.c +++ b/test/udp-test.c @@ -13,7 +13,7 @@ static niova_atomic64_t numPingPongsDone; #define OPTS "ht:s:" -static size_t udpSize = 5000; +static ssize_t udpSize = 5000; static size_t runTime = 1; /** diff --git a/test/work-dispatch-test.c b/test/work-dispatch-test.c index 92965d344..c0b3b6412 100644 --- a/test/work-dispatch-test.c +++ b/test/work-dispatch-test.c @@ -17,7 +17,7 @@ #include #include -#define NUM_SECONDS_TO_RUN_TEST 2ULL +#define NUM_SECONDS_TO_RUN_TEST 2L pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER;