]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
uid-range: make uid_range_intersect() take two UidRange objects
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Sep 2022 01:51:36 +0000 (10:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Sep 2022 11:52:47 +0000 (20:52 +0900)
No functional changes, just refactoring.

src/basic/uid-range.c

index 8e68e0464c5c7711018ce33b3066ff6d46eb8e02..fbc764673c4ebce0fd9746974f44e76272d88d75 100644 (file)
 #include "uid-range.h"
 #include "user-util.h"
 
-static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) {
-        assert(range);
+static bool uid_range_intersect(const UidRange *a, const UidRange *b) {
+        assert(a);
+        assert(b);
 
-        return range->start <= start + nr &&
-                range->start + range->nr >= start;
+        return a->start <= b->start + b->nr && a->start + a->nr >= b->start;
 }
 
 static int uid_range_compare(const UidRange *a, const UidRange *b) {
@@ -51,7 +51,7 @@ static void uid_range_coalesce(UidRange **p, size_t *n) {
                         UidRange *y = (*p)+j;
                         uid_t begin, end;
 
-                        if (!uid_range_intersect(x, y->start, y->nr))
+                        if (!uid_range_intersect(x, y))
                                 break;
 
                         begin = MIN(x->start, y->start);