]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
oom: use CMP() macro
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 26 Nov 2020 23:29:20 +0000 (08:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 27 Nov 2020 05:35:20 +0000 (14:35 +0900)
src/oom/oomd-util.h

index 87ecda80fbce2f64ffabc322ef50608c6a6517c0..0834cbf09d78445d1532eef2ea7b57a5d1c95c35 100644 (file)
@@ -64,24 +64,14 @@ static inline int compare_pgscan(OomdCGroupContext * const *c1, OomdCGroupContex
         assert(c1);
         assert(c2);
 
-        if ((*c1)->pgscan > (*c2)->pgscan)
-                return -1;
-        else if ((*c1)->pgscan < (*c2)->pgscan)
-                return 1;
-        else
-                return 0;
+        return CMP((*c2)->pgscan, (*c1)->pgscan);
 }
 
 static inline int compare_swap_usage(OomdCGroupContext * const *c1, OomdCGroupContext * const *c2) {
         assert(c1);
         assert(c2);
 
-        if ((*c1)->swap_usage > (*c2)->swap_usage)
-                return -1;
-        else if ((*c1)->swap_usage < (*c2)->swap_usage)
-                return 1;
-        else
-                return 0;
+        return CMP((*c2)->swap_usage, (*c1)->swap_usage);
 }
 
 /* Get an array of OomdCGroupContexts from `h`, qsorted from largest to smallest values according to `compare_func`.