diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-09-18 08:39:24 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-09-19 08:02:52 +0900 |
commit | 93bab288956f43c70f2b28a88efdc9effd951bb5 (patch) | |
tree | 453abf294f7bf2aba7ccf7ed37ccd669ec231c95 /src/core/job.c | |
parent | 6058516a14ada1748313af6783f5b4e7e3006654 (diff) | |
download | systemd-93bab288956f43c70f2b28a88efdc9effd951bb5.tar.gz |
tree-wide: use typesafe_qsort()
Diffstat (limited to 'src/core/job.c')
-rw-r--r-- | src/core/job.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/core/job.c b/src/core/job.c index 6c62cdf595..6b17cc1d6f 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -1384,15 +1384,8 @@ void job_add_to_gc_queue(Job *j) { j->in_gc_queue = true; } -static int job_compare(const void *a, const void *b) { - Job *x = *(Job**) a, *y = *(Job**) b; - - if (x->id < y->id) - return -1; - if (x->id > y->id) - return 1; - - return 0; +static int job_compare(Job * const *a, Job * const *b) { + return CMP((*a)->id, (*b)->id); } static size_t sort_job_list(Job **list, size_t n) { @@ -1400,7 +1393,7 @@ static size_t sort_job_list(Job **list, size_t n) { size_t a, b; /* Order by numeric IDs */ - qsort_safe(list, n, sizeof(Job*), job_compare); + typesafe_qsort(list, n, job_compare); /* Filter out duplicates */ for (a = 0, b = 0; a < n; a++) { |