From: Pat Riehecky Date: Mon, 16 Mar 2026 13:18:36 +0000 (-0500) Subject: subid: Move linear allocation into its own function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e83ce1003ccb82fd383556e7d20896b88661afcf;p=thirdparty%2Fshadow.git subid: Move linear allocation into its own function Signed-off-by: Pat Riehecky --- diff --git a/lib/find_new_sub_gids.c b/lib/find_new_sub_gids.c index b5304d980..3e6cc2d64 100644 --- a/lib/find_new_sub_gids.c +++ b/lib/find_new_sub_gids.c @@ -21,14 +21,16 @@ /* - * find_new_sub_gids - Find a new unused range of GIDs. + * find_new_sub_gids_linear - Find an unused subordinate GID range via + * linear search. * - * If successful, find_new_sub_gids provides a range of unused - * user IDs in the [SUB_GID_MIN:SUB_GID_MAX] range. + * Loads SUB_GID_COUNT from login.defs and writes the allocated count back + * to *range_count on success. * * Return 0 on success, -1 if no unused GIDs are available. */ -int find_new_sub_gids (id_t *range_start, unsigned long *range_count) +static int +find_new_sub_gids_linear(id_t *range_start, unsigned long *range_count) { unsigned long min, max; unsigned long count; @@ -46,7 +48,18 @@ int find_new_sub_gids (id_t *range_start, unsigned long *range_count) *range_count = count; return 0; } + +/* + * find_new_sub_gids - Find a new unused range of subordinate GIDs. + * + * Return 0 on success, -1 if no unused GIDs are available. + */ +int +find_new_sub_gids(id_t *range_start, unsigned long *range_count) +{ + return find_new_sub_gids_linear(range_start, range_count); +} + #else /* !ENABLE_SUBIDS */ extern int ISO_C_forbids_an_empty_translation_unit; #endif /* !ENABLE_SUBIDS */ - diff --git a/lib/find_new_sub_uids.c b/lib/find_new_sub_uids.c index 30e9c46c2..662ed7def 100644 --- a/lib/find_new_sub_uids.c +++ b/lib/find_new_sub_uids.c @@ -21,14 +21,16 @@ /* - * find_new_sub_uids - Find a new unused range of UIDs. + * find_new_sub_uids_linear - Find an unused subordinate UID range via + * linear search. * - * If successful, find_new_sub_uids provides a range of unused - * user IDs in the [SUB_UID_MIN:SUB_UID_MAX] range. + * Loads SUB_UID_COUNT from login.defs and writes the allocated count back + * to *range_count on success. * * Return 0 on success, -1 if no unused UIDs are available. */ -int find_new_sub_uids (id_t *range_start, unsigned long *range_count) +static int +find_new_sub_uids_linear(id_t *range_start, unsigned long *range_count) { unsigned long min, max; unsigned long count; @@ -46,7 +48,18 @@ int find_new_sub_uids (id_t *range_start, unsigned long *range_count) *range_count = count; return 0; } + +/* + * find_new_sub_uids - Find a new unused range of subordinate UIDs. + * + * Return 0 on success, -1 if no unused UIDs are available. + */ +int +find_new_sub_uids(id_t *range_start, unsigned long *range_count) +{ + return find_new_sub_uids_linear(range_start, range_count); +} + #else /* !ENABLE_SUBIDS */ extern int ISO_C_forbids_an_empty_translation_unit; #endif /* !ENABLE_SUBIDS */ -