From: Arran Cudbard-Bell Date: Mon, 30 Sep 2019 14:54:51 +0000 (-0500) Subject: Fix comparators to return a number within a limited range X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b17f29ef8a1745da69b791303c986fa183c06ac0;p=thirdparty%2Ffreeradius-server.git Fix comparators to return a number within a limited range --- diff --git a/src/lib/io/master.c b/src/lib/io/master.c index 2584c5cabe9..5bfb9a676b3 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -150,7 +150,7 @@ static fr_event_update_t resume_read[] = { * Return negative numbers to put 'one' at the top of the heap. * Return positive numbers to put 'two' at the top of the heap. */ -static int pending_packet_cmp(void const *one, void const *two) +static int8_t pending_packet_cmp(void const *one, void const *two) { fr_io_pending_packet_t const *a = one; fr_io_pending_packet_t const *b = two; @@ -181,7 +181,7 @@ static int pending_packet_cmp(void const *one, void const *two) * Order clients in the pending_clients heap, based on the * packets that they contain. */ -static int pending_client_cmp(void const *one, void const *two) +static int8_t pending_client_cmp(void const *one, void const *two) { fr_io_pending_packet_t const *a; fr_io_pending_packet_t const *b; @@ -199,7 +199,7 @@ static int pending_client_cmp(void const *one, void const *two) } -static int address_cmp(void const *one, void const *two) +static int8_t address_cmp(void const *one, void const *two) { int rcode; fr_io_address_t const *a = one; @@ -977,7 +977,7 @@ static fr_io_pending_packet_t *fr_io_pending_alloc(fr_io_client_t *client, * This function is only used for the "main" socket. Clients * from connections do not use it. */ -static int alive_client_cmp(void const *one, void const *two) +static int8_t alive_client_cmp(void const *one, void const *two) { fr_io_client_t const *a = one; fr_io_client_t const *b = two; diff --git a/src/lib/io/network.c b/src/lib/io/network.c index 47519c9bd81..2675fea1b96 100644 --- a/src/lib/io/network.c +++ b/src/lib/io/network.c @@ -131,7 +131,7 @@ struct fr_network_t { static void fr_network_post_event(fr_event_list_t *el, fr_time_t now, void *uctx); static int fr_network_pre_event(void *ctx, fr_time_t wake); -static int reply_cmp(void const *one, void const *two) +static int8_t reply_cmp(void const *one, void const *two) { fr_channel_data_t const *a = one, *b = two; int ret; @@ -142,7 +142,7 @@ static int reply_cmp(void const *one, void const *two) return (a->m.when > b->m.when) - (a->m.when < b->m.when); } -static int waiting_cmp(void const *one, void const *two) +static int8_t waiting_cmp(void const *one, void const *two) { fr_channel_data_t const *a = one, *b = two; int ret; diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index bea81bd4ab6..8c958f1834f 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -1127,7 +1127,7 @@ static int fr_worker_pre_event(void *ctx, fr_time_t wake) /** * Track a channel in the "to_decode" or "localized" heap. */ -static int worker_message_cmp(void const *one, void const *two) +static int8_t worker_message_cmp(void const *one, void const *two) { fr_channel_data_t const *a = one, *b = two; int ret; @@ -1141,7 +1141,7 @@ static int worker_message_cmp(void const *one, void const *two) /** * Track a REQUEST in the "runnable" heap. */ -static int worker_runnable_cmp(void const *one, void const *two) +static int8_t worker_runnable_cmp(void const *one, void const *two) { REQUEST const *a = one, *b = two; int ret; @@ -1155,7 +1155,7 @@ static int worker_runnable_cmp(void const *one, void const *two) /** * Track a REQUEST in the "time_order" heap. */ -static int worker_time_order_cmp(void const *one, void const *two) +static int8_t worker_time_order_cmp(void const *one, void const *two) { REQUEST const *a = one, *b = two; diff --git a/src/lib/server/pool.c b/src/lib/server/pool.c index 735af13845a..5bdc1218ce8 100644 --- a/src/lib/server/pool.c +++ b/src/lib/server/pool.c @@ -168,7 +168,7 @@ static const CONF_PARSER pool_config[] = { /** Order connections by reserved most recently */ -static int last_reserved_cmp(void const *one, void const *two) +static int8_t last_reserved_cmp(void const *one, void const *two) { fr_pool_connection_t const *a = one, *b = two; @@ -177,7 +177,7 @@ static int last_reserved_cmp(void const *one, void const *two) /** Order connections by released longest ago */ -static int last_released_cmp(void const *one, void const *two) +static int8_t last_released_cmp(void const *one, void const *two) { fr_pool_connection_t const *a = one, *b = two; diff --git a/src/lib/util/event.c b/src/lib/util/event.c index 6a4af10e53b..01c142cc979 100644 --- a/src/lib/util/event.c +++ b/src/lib/util/event.c @@ -327,7 +327,7 @@ struct fr_event_list { * - -1 if a should occur earlier than b. * - 0 if both events occur at the same time. */ -static int fr_event_timer_cmp(void const *a, void const *b) +static int8_t fr_event_timer_cmp(void const *a, void const *b) { fr_event_timer_t const *ev_a = a, *ev_b = b; diff --git a/src/lib/util/heap.h b/src/lib/util/heap.h index 8bcbaae54ce..02fad0350a8 100644 --- a/src/lib/util/heap.h +++ b/src/lib/util/heap.h @@ -38,7 +38,7 @@ extern "C" { * Return negative numbers to put 'a' at the top of the heap. * Return positive numbers to put 'b' at the top of the heap. */ -typedef int (*fr_heap_cmp_t)(void const *a, void const *b); +typedef int8_t (*fr_heap_cmp_t)(void const *a, void const *b); typedef struct fr_heap_t fr_heap_t; diff --git a/src/lib/util/time.h b/src/lib/util/time.h index 46e771b44b8..101793dbcaf 100644 --- a/src/lib/util/time.h +++ b/src/lib/util/time.h @@ -202,7 +202,7 @@ static inline int64_t fr_time_delta_to_sec(fr_time_delta_t delta) * - 0 if a == b * - -1 if a < b */ -static inline int fr_time_cmp(fr_time_t a, fr_time_t b) +static inline int8_t fr_time_cmp(fr_time_t a, fr_time_t b) { return (a > b) - (a < b); } diff --git a/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c b/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c index 5ed82b6f21d..e26e16f355b 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c @@ -57,7 +57,7 @@ static int cache_entry_cmp(void const *one, void const *two) * * There may be multiple entries with the same expiry time. */ -static int cache_heap_cmp(void const *one, void const *two) +static int8_t cache_heap_cmp(void const *one, void const *two) { rlm_cache_entry_t const *a = one, *b = two; diff --git a/src/modules/rlm_radius/rlm_radius_udp.c b/src/modules/rlm_radius/rlm_radius_udp.c index 5a15bbcb79f..56a61c71c28 100644 --- a/src/modules/rlm_radius/rlm_radius_udp.c +++ b/src/modules/rlm_radius/rlm_radius_udp.c @@ -267,7 +267,7 @@ static void conn_transition(fr_io_connection_t *c, fr_io_connection_state_t stat static void state_transition(fr_io_request_t *u, fr_io_request_state_t state, fr_io_connection_t *c); static void conn_zombie_timeout(UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx); -static int conn_cmp(void const *one, void const *two) +static int8_t conn_cmp(void const *one, void const *two) { fr_io_connection_t const *a = talloc_get_type_abort_const(one, fr_io_connection_t); fr_io_connection_t const *b = talloc_get_type_abort_const(two, fr_io_connection_t); @@ -287,7 +287,7 @@ static int conn_cmp(void const *one, void const *two) * Status-Server packets are always sorted before other packets, by * virtue of request->async->recv_time always being zero. */ -static int queue_cmp(void const *one, void const *two) +static int8_t queue_cmp(void const *one, void const *two) { fr_io_request_t const *a = one; fr_io_request_t const *b = two;