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:
parent
bc861c2e09
commit
dc5f9c6f39
|
@ -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 = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue