Skip to content

Commit bd4b4d6

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)
1 parent 1191cc3 commit bd4b4d6

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
@@ -178,7 +178,7 @@ static const struct {
178178
};
179179

180180
static int table_add_uid_boundaries(Table *table, const UidRange *p) {
181-
int r;
181+
int r, n_added = 0;
182182

183183
assert(table);
184184

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

253-
return ELEMENTSOF(uid_range_table) * 2;
255+
return n_added;
254256
}
255257

256258
static int add_unavailable_uid(Table *table, uid_t start, uid_t end) {
@@ -541,7 +543,7 @@ static int show_group(GroupRecord *gr, Table *table) {
541543
}
542544

543545
static int table_add_gid_boundaries(Table *table, const UidRange *p) {
544-
int r;
546+
int r, n_added = 0;
545547

546548
assert(table);
547549

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

611-
return ELEMENTSOF(uid_range_table) * 2;
615+
return n_added;
612616
}
613617

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

0 commit comments

Comments
 (0)