busctl,sd-lldp: explicitly specify type of argument in compare function

Several functions are shared by qsort and hash_ops or Prioq.
This makes these functions explicitly specify argument type,
and cast to __compar_fn_t where necessary.
This commit is contained in:
Yu Watanabe 2018-09-19 08:28:50 +09:00
parent bc861c2e09
commit dc5f9c6f39
4 changed files with 6 additions and 7 deletions

View File

@ -719,8 +719,7 @@ static void member_hash_func(const void *p, struct siphash *state) {
string_hash_func(m->interface, state);
}
static int member_compare_func(const void *a, const void *b) {
const Member *x = a, *y = b;
static int member_compare_func(const Member *x, const Member *y) {
int d;
assert(x);
@ -911,7 +910,7 @@ static int on_property(const char *interface, const char *name, const char *sign
static int introspect(int argc, char **argv, void *userdata) {
static const struct hash_ops member_hash_ops = {
.hash = member_hash_func,
.compare = member_compare_func,
.compare = (__compar_fn_t) member_compare_func,
};
static const XMLIntrospectOps ops = {

View File

@ -18,8 +18,7 @@ static void lldp_neighbor_id_hash_func(const void *p, struct siphash *state) {
siphash24_compress(&id->port_id_size, sizeof(id->port_id_size), state);
}
static int lldp_neighbor_id_compare_func(const void *a, const void *b) {
const LLDPNeighborID *x = a, *y = b;
int lldp_neighbor_id_compare_func(const LLDPNeighborID *x, const LLDPNeighborID *y) {
int r;
r = memcmp(x->chassis_id, y->chassis_id, MIN(x->chassis_id_size, y->chassis_id_size));
@ -39,7 +38,7 @@ static int lldp_neighbor_id_compare_func(const void *a, const void *b) {
const struct hash_ops lldp_neighbor_id_hash_ops = {
.hash = lldp_neighbor_id_hash_func,
.compare = lldp_neighbor_id_compare_func
.compare = (__compar_fn_t) lldp_neighbor_id_compare_func,
};
int lldp_neighbor_prioq_compare_func(const void *a, const void *b) {

View File

@ -81,6 +81,7 @@ static inline void* LLDP_NEIGHBOR_TLV_DATA(const sd_lldp_neighbor *n) {
}
extern const struct hash_ops lldp_neighbor_id_hash_ops;
int lldp_neighbor_id_compare_func(const LLDPNeighborID *x, const LLDPNeighborID *y);
int lldp_neighbor_prioq_compare_func(const void *a, const void *b);
sd_lldp_neighbor *lldp_neighbor_unlink(sd_lldp_neighbor *n);

View File

@ -372,7 +372,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
}
static int neighbor_compare_func(sd_lldp_neighbor * const *a, sd_lldp_neighbor * const *b) {
return lldp_neighbor_id_hash_ops.compare(&(*a)->id, &(*b)->id);
return lldp_neighbor_id_compare_func(&(*a)->id, &(*b)->id);
}
static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {