tree-wide: Convert compare_func's to use CMP() macro wherever possible.
Looked for definitions of functions using the *_compare_func() suffix. Tested: - Unit tests passed (ninja -C build/ test) - Installed this build and booted with it.
This commit is contained in:
@@ -26,22 +26,15 @@ static int lldp_neighbor_id_compare_func(const void *a, const void *b) {
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
if (x->chassis_id_size < y->chassis_id_size)
|
||||
return -1;
|
||||
|
||||
if (x->chassis_id_size > y->chassis_id_size)
|
||||
return 1;
|
||||
r = CMP(x->chassis_id_size, y->chassis_id_size);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(x->port_id, y->port_id, MIN(x->port_id_size, y->port_id_size));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
if (x->port_id_size < y->port_id_size)
|
||||
return -1;
|
||||
if (x->port_id_size > y->port_id_size)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->port_id_size, y->port_id_size);
|
||||
}
|
||||
|
||||
const struct hash_ops lldp_neighbor_id_hash_ops = {
|
||||
@@ -52,13 +45,7 @@ const struct hash_ops lldp_neighbor_id_hash_ops = {
|
||||
int lldp_neighbor_prioq_compare_func(const void *a, const void *b) {
|
||||
const sd_lldp_neighbor *x = a, *y = b;
|
||||
|
||||
if (x->until < y->until)
|
||||
return -1;
|
||||
|
||||
if (x->until > y->until)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->until, y->until);
|
||||
}
|
||||
|
||||
_public_ sd_lldp_neighbor *sd_lldp_neighbor_ref(sd_lldp_neighbor *n) {
|
||||
|
||||
@@ -125,6 +125,7 @@ void client_id_hash_func(const void *p, struct siphash *state) {
|
||||
|
||||
int client_id_compare_func(const void *_a, const void *_b) {
|
||||
const DHCPClientId *a, *b;
|
||||
int r;
|
||||
|
||||
a = _a;
|
||||
b = _b;
|
||||
@@ -132,8 +133,9 @@ int client_id_compare_func(const void *_a, const void *_b) {
|
||||
assert(!a->length || a->data);
|
||||
assert(!b->length || b->data);
|
||||
|
||||
if (a->length != b->length)
|
||||
return a->length < b->length ? -1 : 1;
|
||||
r = CMP(a->length, b->length);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
return memcmp(a->data, b->data, a->length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user