Skip to content

Commit 366ac4a

Browse files
poetteringbluca
authored andcommitted
userdbctl: fix counting
Fixes: #35294 (cherry picked from commit 7f8a4f1) (cherry picked from commit 3d85366) (cherry picked from commit 9d0e453) (cherry picked from commit 20bf8b0) (cherry picked from commit bd4b4d6)
1 parent 427e392 commit 366ac4a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/userdb/userdbctl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static const struct {
177177
};
178178

179179
static int table_add_uid_boundaries(Table *table, const UidRange *p) {
180-
int r;
180+
int r, n_added = 0;
181181

182182
assert(table);
183183

@@ -247,9 +247,11 @@ static int table_add_uid_boundaries(Table *table, const UidRange *p) {
247247
TABLE_INT, 1); /* sort after any other entry with the same UID */
248248
if (r < 0)
249249
return table_log_add_error(r);
250+
251+
n_added += 2;
250252
}
251253

252-
return ELEMENTSOF(uid_range_table) * 2;
254+
return n_added;
253255
}
254256

255257
static int add_unavailable_uid(Table *table, uid_t start, uid_t end) {
@@ -540,7 +542,7 @@ static int show_group(GroupRecord *gr, Table *table) {
540542
}
541543

542544
static int table_add_gid_boundaries(Table *table, const UidRange *p) {
543-
int r;
545+
int r, n_added = 0;
544546

545547
assert(table);
546548

@@ -605,9 +607,11 @@ static int table_add_gid_boundaries(Table *table, const UidRange *p) {
605607
TABLE_INT, 1); /* sort after any other entry with the same GID */
606608
if (r < 0)
607609
return table_log_add_error(r);
610+
611+
n_added += 2;
608612
}
609613

610-
return ELEMENTSOF(uid_range_table) * 2;
614+
return n_added;
611615
}
612616

613617
static int add_unavailable_gid(Table *table, uid_t start, uid_t end) {

0 commit comments

Comments
 (0)