tree-wide: use CMP() macros where applicable
This commit is contained in:
parent
b7c09eaf1c
commit
9c57a73b13
|
@ -62,18 +62,13 @@
|
|||
|
||||
static int client_context_compare(const void *a, const void *b) {
|
||||
const ClientContext *x = a, *y = b;
|
||||
int r;
|
||||
|
||||
if (x->timestamp < y->timestamp)
|
||||
return -1;
|
||||
if (x->timestamp > y->timestamp)
|
||||
return 1;
|
||||
r = CMP(x->timestamp, y->timestamp);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
if (x->pid < y->pid)
|
||||
return -1;
|
||||
if (x->pid > y->pid)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->pid, y->pid);
|
||||
}
|
||||
|
||||
static int client_context_new(Server *s, pid_t pid, ClientContext **ret) {
|
||||
|
|
|
@ -1945,13 +1945,7 @@ static int timeout_compare(const void *a, const void *b) {
|
|||
if (x->timeout_usec == 0 && y->timeout_usec != 0)
|
||||
return 1;
|
||||
|
||||
if (x->timeout_usec < y->timeout_usec)
|
||||
return -1;
|
||||
|
||||
if (x->timeout_usec > y->timeout_usec)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->timeout_usec, y->timeout_usec);
|
||||
}
|
||||
|
||||
_public_ int sd_bus_call_async(
|
||||
|
|
|
@ -314,6 +314,7 @@ static sd_event *event_resolve(sd_event *e) {
|
|||
|
||||
static int pending_prioq_compare(const void *a, const void *b) {
|
||||
const sd_event_source *x = a, *y = b;
|
||||
int r;
|
||||
|
||||
assert(x->pending);
|
||||
assert(y->pending);
|
||||
|
@ -325,22 +326,17 @@ static int pending_prioq_compare(const void *a, const void *b) {
|
|||
return 1;
|
||||
|
||||
/* Lower priority values first */
|
||||
if (x->priority < y->priority)
|
||||
return -1;
|
||||
if (x->priority > y->priority)
|
||||
return 1;
|
||||
r = CMP(x->priority, y->priority);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
/* Older entries first */
|
||||
if (x->pending_iteration < y->pending_iteration)
|
||||
return -1;
|
||||
if (x->pending_iteration > y->pending_iteration)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->pending_iteration, y->pending_iteration);
|
||||
}
|
||||
|
||||
static int prepare_prioq_compare(const void *a, const void *b) {
|
||||
const sd_event_source *x = a, *y = b;
|
||||
int r;
|
||||
|
||||
assert(x->prepare);
|
||||
assert(y->prepare);
|
||||
|
@ -354,18 +350,12 @@ static int prepare_prioq_compare(const void *a, const void *b) {
|
|||
/* Move most recently prepared ones last, so that we can stop
|
||||
* preparing as soon as we hit one that has already been
|
||||
* prepared in the current iteration */
|
||||
if (x->prepare_iteration < y->prepare_iteration)
|
||||
return -1;
|
||||
if (x->prepare_iteration > y->prepare_iteration)
|
||||
return 1;
|
||||
r = CMP(x->prepare_iteration, y->prepare_iteration);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
/* Lower priority values first */
|
||||
if (x->priority < y->priority)
|
||||
return -1;
|
||||
if (x->priority > y->priority)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->priority, y->priority);
|
||||
}
|
||||
|
||||
static int earliest_time_prioq_compare(const void *a, const void *b) {
|
||||
|
@ -387,12 +377,7 @@ static int earliest_time_prioq_compare(const void *a, const void *b) {
|
|||
return 1;
|
||||
|
||||
/* Order by time */
|
||||
if (x->time.next < y->time.next)
|
||||
return -1;
|
||||
if (x->time.next > y->time.next)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->time.next, y->time.next);
|
||||
}
|
||||
|
||||
static usec_t time_event_source_latest(const sd_event_source *s) {
|
||||
|
@ -418,12 +403,7 @@ static int latest_time_prioq_compare(const void *a, const void *b) {
|
|||
return 1;
|
||||
|
||||
/* Order by time */
|
||||
if (time_event_source_latest(x) < time_event_source_latest(y))
|
||||
return -1;
|
||||
if (time_event_source_latest(x) > time_event_source_latest(y))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(time_event_source_latest(x), time_event_source_latest(y));
|
||||
}
|
||||
|
||||
static int exit_prioq_compare(const void *a, const void *b) {
|
||||
|
|
|
@ -490,13 +490,7 @@ static int timeout_compare(const void *a, const void *b) {
|
|||
if (x->timeout == 0 && y->timeout != 0)
|
||||
return 1;
|
||||
|
||||
if (x->timeout < y->timeout)
|
||||
return -1;
|
||||
|
||||
if (x->timeout > y->timeout)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return CMP(x->timeout, y->timeout);
|
||||
}
|
||||
|
||||
int sd_netlink_call_async(sd_netlink *nl,
|
||||
|
|
Loading…
Reference in New Issue