]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/subordinateio.c: append_range(): Use reallocf(3)-like calling conventions
authorAlejandro Colomar <alx@kernel.org>
Sun, 24 Aug 2025 07:48:23 +0000 (09:48 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 19:24:03 +0000 (13:24 -0600)
By returning the new pointer, we can simplify the implementation,
and we avoid a return-by-parameter.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/subordinateio.c

index 114d0b796cdd60b5d7271441ca1e87abed1bf230..7aa912d00a260cc65faa9ffd464cd3f73fa4e9d1 100644 (file)
@@ -275,16 +275,17 @@ static const struct subordinate_range *find_range(struct commonio_db *db,
 static bool have_range(struct commonio_db *db,
                       const char *owner, unsigned long start, unsigned long count);
 
-static bool append_range(struct subid_range **ranges, const struct subordinate_range *new, int n)
+static struct subid_range *
+append_range(struct subid_range *ranges, const struct subordinate_range *new, int n)
 {
-       *ranges = REALLOCF(*ranges, n + 1, struct subid_range);
-       if (!*ranges)
-               return false;
+       ranges = REALLOCF(ranges, n + 1, struct subid_range);
+       if (ranges == NULL)
+               return NULL;
 
-       (*ranges)[n].start = new->start;
-       (*ranges)[n].count = new->count;
+       ranges[n].start = new->start;
+       ranges[n].count = new->count;
 
-       return true;
+       return ranges;
 }
 
 void free_subordinate_ranges(struct subordinate_range **ranges, int count)
@@ -916,7 +917,8 @@ int list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_r
                if (   streq(range->owner, owner)
                    || (have_owner_id && streq(range->owner, id)))
                {
-                       if (!append_range(&ranges, range, count++)) {
+                       ranges = append_range(ranges, range, count++);
+                       if (ranges == NULL) {
                                count = -1;
                                goto out;
                        }