]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/uid-range.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / shared / uid-range.c
index 74c3be4a137fe59764e5710192a507302e838cd0..c38b7cc984a6d12cda912b930014da8994ae2c40 100644 (file)
@@ -1,5 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include "util.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macro.h"
 #include "uid-range.h"
+#include "user-util.h"
 
 static bool uid_range_intersect(UidRange *range, uid_t start, uid_t nr) {
         assert(range);
@@ -51,7 +55,7 @@ static void uid_range_coalesce(UidRange **p, unsigned *n) {
                                 if (*n > j+1)
                                         memmove(y, y+1, sizeof(UidRange) * (*n - j -1));
 
-                                (*n) --;
+                                (*n)--;
                                 j--;
                         }
                 }
@@ -161,7 +165,7 @@ int uid_range_add_str(UidRange **p, unsigned *n, const char *s) {
 }
 
 int uid_range_next_lower(const UidRange *p, unsigned n, uid_t *uid) {
-        uid_t closest = (uid_t) -1, candidate;
+        uid_t closest = UID_INVALID, candidate;
         unsigned i;
 
         assert(p);
@@ -184,7 +188,7 @@ int uid_range_next_lower(const UidRange *p, unsigned n, uid_t *uid) {
                         closest = end;
         }
 
-        if (closest == (uid_t) -1)
+        if (closest == UID_INVALID)
                 return -EBUSY;
 
         *uid = closest;