diff --git a/src/include/libradius.h b/src/include/libradius.h index aa9d05bb9f38..548c33e84fba 100644 --- a/src/include/libradius.h +++ b/src/include/libradius.h @@ -760,7 +760,8 @@ typedef enum { #define RBTREE_FLAG_REPLACE (1 << 0) #define RBTREE_FLAG_LOCK (1 << 1) -typedef int (*rb_comparator_t)(void const *a, void const *b); +typedef int (*rb_comparator_t)(void const *ctx, void const *data); +typedef int (*rb_walker_t)(void *ctx, void *data); typedef void (*rb_free_t)(void *data); rbtree_t *rbtree_create(rb_comparator_t compare, rb_free_t node_free, int flags); @@ -791,7 +792,7 @@ void *rbtree_node2data(rbtree_t *tree, rbnode_t *node); * or 2 to delete the current node and continue. This may be * used to batch-delete select nodes from a locked rbtree. */ -int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_comparator_t compare, void *context); +int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *context); /* * Find a matching data item in an rbtree and, if one is found, diff --git a/src/include/packet.h b/src/include/packet.h index 03f77a4783c2..535173ddee19 100644 --- a/src/include/packet.h +++ b/src/include/packet.h @@ -61,7 +61,7 @@ bool fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd, int proto, bool fr_packet_list_socket_del(fr_packet_list_t *pl, int sockfd); bool fr_packet_list_socket_freeze(fr_packet_list_t *pl, int sockfd); bool fr_packet_list_socket_thaw(fr_packet_list_t *pl, int sockfd); -int fr_packet_list_walk(fr_packet_list_t *pl, void *ctx, rb_comparator_t callback); +int fr_packet_list_walk(fr_packet_list_t *pl, void *ctx, rb_walker_t callback); int fr_packet_list_fd_set(fr_packet_list_t *pl, fd_set *set); RADIUS_PACKET *fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set); diff --git a/src/lib/packet.c b/src/lib/packet.c index bd079d6291fe..d5c4c089aa8a 100644 --- a/src/lib/packet.c +++ b/src/lib/packet.c @@ -820,7 +820,7 @@ bool fr_packet_list_id_free(fr_packet_list_t *pl, * 1 means delete current node and stop * 2 means delete current node and continue */ -int fr_packet_list_walk(fr_packet_list_t *pl, void *ctx, rb_comparator_t callback) +int fr_packet_list_walk(fr_packet_list_t *pl, void *ctx, rb_walker_t callback) { if (!pl || !callback) return 0; diff --git a/src/lib/rbtree.c b/src/lib/rbtree.c index 30e02934e4a9..2bd4616e3bc5 100644 --- a/src/lib/rbtree.c +++ b/src/lib/rbtree.c @@ -577,7 +577,7 @@ void *rbtree_callbydata(rbtree_t *tree, void const *data, rb_comparator_t compar * We call ourselves recursively for each function, but that's OK, * as the stack is only log(N) deep, which is ~12 entries deep. */ -static int walk_node_pre_order(rbnode_t *x, rb_comparator_t compare, void *context) +static int walk_node_pre_order(rbnode_t *x, rb_walker_t compare, void *context) { int rcode; rbnode_t *left, *right; @@ -604,7 +604,7 @@ static int walk_node_pre_order(rbnode_t *x, rb_comparator_t compare, void *conte /** rbtree_in_order * */ -static int walk_node_in_order(rbnode_t *x, rb_comparator_t compare, void *context) +static int walk_node_in_order(rbnode_t *x, rb_walker_t compare, void *context) { int rcode; rbnode_t *right; @@ -631,7 +631,7 @@ static int walk_node_in_order(rbnode_t *x, rb_comparator_t compare, void *contex /** rbtree_post_order * */ -static int walk_node_post_order(rbnode_t *x, rb_comparator_t compare, void *context) +static int walk_node_post_order(rbnode_t *x, rb_walker_t compare, void *context) { int rcode; @@ -665,7 +665,7 @@ static int walk_node_post_order(rbnode_t *x, rb_comparator_t compare, void *cont * 1 - delete the node and stop walking * 2 - delete the node and continue walking */ -static int walk_delete_order(rbtree_t *tree, rb_comparator_t compare, void *context) +static int walk_delete_order(rbtree_t *tree, rb_walker_t compare, void *context) { rbnode_t *solid, *x; int rcode = 0; @@ -718,7 +718,7 @@ static int walk_delete_order(rbtree_t *tree, rb_comparator_t compare, void *cont * The compare function should return 0 to continue walking. * Any other value stops the walk, and is returned. */ -int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_comparator_t compare, void *context) +int rbtree_walk(rbtree_t *tree, rb_order_t order, rb_walker_t compare, void *context) { int rcode; diff --git a/src/main/process.c b/src/main/process.c index bf9b8dfdb7cd..8c4a5bc05000 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -1678,10 +1678,10 @@ static void add_jitter(struct timeval *when) /* * Called by socket_del to remove requests with this socket */ -static int eol_proxy_listener(void const *ctx, void const *data) +static int eol_proxy_listener(void *ctx, void *data) { - rad_listen_t const *this = ctx; - RADIUS_PACKET * const *proxy_p = data; + rad_listen_t *this = ctx; + RADIUS_PACKET **proxy_p = data; REQUEST *request; request = fr_packet2myptr(REQUEST, proxy, proxy_p); @@ -1707,10 +1707,10 @@ static int eol_proxy_listener(void const *ctx, void const *data) } #endif /* WITH_PROXY */ -static int eol_listener(void const *ctx, void const *data) +static int eol_listener(void *ctx, void *data) { - rad_listen_t const *this = ctx; - RADIUS_PACKET * const *packet_p = data; + rad_listen_t *this = ctx; + RADIUS_PACKET **packet_p = data; REQUEST *request; request = fr_packet2myptr(REQUEST, packet, packet_p); @@ -3919,8 +3919,7 @@ int event_new_fd(rad_listen_t *this) */ if (this->type == RAD_LISTEN_PROXY) { PTHREAD_MUTEX_LOCK(&proxy_mutex); - fr_packet_list_walk(proxy_list, this, - eol_proxy_listener); + fr_packet_list_walk(proxy_list, this, eol_proxy_listener); if (!fr_packet_list_socket_del(proxy_list, this->fd)) { ERROR("Fatal error removing socket: %s", @@ -3937,8 +3936,7 @@ int event_new_fd(rad_listen_t *this) /* * EOL all requests using this socket. */ - fr_packet_list_walk(pl, this, - eol_listener); + fr_packet_list_walk(pl, this, eol_listener); } /* @@ -4267,7 +4265,7 @@ int radius_event_init(CONF_SECTION *cs, int have_children) } -static int proxy_delete_cb(UNUSED void const *ctx, void const *data) +static int proxy_delete_cb(UNUSED void *ctx, void *data) { REQUEST *request = fr_packet2myptr(REQUEST, packet, data); @@ -4291,7 +4289,7 @@ static int proxy_delete_cb(UNUSED void const *ctx, void const *data) } -static int request_delete_cb(UNUSED void const *ctx, void const *data) +static int request_delete_cb(UNUSED void *ctx, void *data) { REQUEST *request = fr_packet2myptr(REQUEST, packet, data); diff --git a/src/main/radclient.c b/src/main/radclient.c index e79b768d5776..33430204f4fa 100644 --- a/src/main/radclient.c +++ b/src/main/radclient.c @@ -457,9 +457,9 @@ static int filename_cmp(void const *one, void const *two) return strcmp((char const *) one, (char const *) two); } -static int filename_walk(UNUSED void const *context, void const *data) +static int filename_walk(UNUSED void *context, void *data) { - char const *filename = data; + char const *filename = data; /* * Read request(s) from the file. diff --git a/src/tests/rbmonkey.c b/src/tests/rbmonkey.c index 1f49f033f906..a22d3fa02ac1 100644 --- a/src/tests/rbmonkey.c +++ b/src/tests/rbmonkey.c @@ -54,7 +54,7 @@ static int comp(void const *a, void const *b) } #if 0 -static int print_cb(UNUSED void const *ctx, void const *i) +static int print_cb(UNUSED void *ctx, void *i) { fprintf(stderr, "%i\n", *(int*)i); return 0; @@ -66,7 +66,7 @@ static int print_cb(UNUSED void const *ctx, void const *i) static int r = 0; static int rvals[MAXSIZE]; -static int store_cb(UNUSED void const *ctx, void const *i) +static int store_cb(UNUSED void *ctx, void *i) { rvals[r++] = *(int const *)i; return 0; @@ -74,9 +74,9 @@ static int store_cb(UNUSED void const *ctx, void const *i) static int mask; -static int filter_cb(UNUSED void const *ctx, void const *i) +static int filter_cb(UNUSED void *ctx, void *i) { - if ((*(int const *)i & mask) == (*(int const *)ctx & mask)) { + if ((*(int *)i & mask) == (*(int *)ctx & mask)) { return 2; } return 0;