]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix comparators to return a number within a limited range
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 30 Sep 2019 14:54:51 +0000 (09:54 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 30 Sep 2019 14:54:51 +0000 (09:54 -0500)
src/lib/io/master.c
src/lib/io/network.c
src/lib/io/worker.c
src/lib/server/pool.c
src/lib/util/event.c
src/lib/util/heap.h
src/lib/util/time.h
src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c
src/modules/rlm_radius/rlm_radius_udp.c

index 2584c5cabe9f82ee602da4a2da710a487f73dc4e..5bfb9a676b38254f7768430c01d80ca8ff822f2a 100644 (file)
@@ -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;
index 47519c9bd81cb3e4dcee6cfa85052fef379021a9..2675fea1b9695fd262fff35def6f4647ab12e6d1 100644 (file)
@@ -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;
index bea81bd4ab6830810f83379f0eb0bd9bd90c523d..8c958f1834fd4db77304e44b355e9541c30077d2 100644 (file)
@@ -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;
 
index 735af13845a2fa86725f6451d25cffd4b8270f98..5bdc1218ce81b2cd669b2377914eba2a3102332c 100644 (file)
@@ -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;
 
index 6a4af10e53bfcd144515883cfaac082dcc0a77dd..01c142cc979aba73f2f630894842c2de6e2df00b 100644 (file)
@@ -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;
 
index 8bcbaae54ceaacb99ff5f9d7ea87a005f4495929..02fad0350a8b2cd4a9bd9eab663cf2e29ecab935 100644 (file)
@@ -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;
 
index 46e771b44b8a7b5b0e9f707374244b74eb28c706..101793dbcaf01fcb67c7038d359af451d20cade1 100644 (file)
@@ -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);
 }
index 5ed82b6f21d74053f6c4761cf6fec12e5fb45e94..e26e16f355b49b38c912cff87ab6b7b5b17a6066 100644 (file)
@@ -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;
 
index 5a15bbcb79fe04617c65abf8ee891e8f264bbc74..56a61c71c2850aabbfaf6dc23ffeae4ebe6c2c35 100644 (file)
@@ -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;