From: Alejandro Colomar Date: Sat, 15 Nov 2025 20:47:56 +0000 (+0100) Subject: lib/, src/: Rename REALLOCF() => reallocf_T() X-Git-Tag: 4.19.0-rc1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3de69c9668a77df1a27d3e9abf01396b65c0f2c2;p=thirdparty%2Fshadow.git lib/, src/: Rename REALLOCF() => reallocf_T() The 'T' in the name notes that this API is a type-safe variant of the API it wraps. This makes the names more explicative. Signed-off-by: Alejandro Colomar --- diff --git a/lib/addgrps.c b/lib/addgrps.c index eda3878f..6ab34dcb 100644 --- a/lib/addgrps.c +++ b/lib/addgrps.c @@ -44,7 +44,7 @@ add_groups(const char *list) if (gids == NULL) return -1; - gids = REALLOCF(gids, n + strchrscnt(list, ",:") + 1, gid_t); + gids = reallocf_T(gids, n + strchrscnt(list, ",:") + 1, gid_t); if (gids == NULL) return -1; diff --git a/lib/alloc/reallocf.h b/lib/alloc/reallocf.h index 009ae79b..c3522829 100644 --- a/lib/alloc/reallocf.h +++ b/lib/alloc/reallocf.h @@ -15,8 +15,9 @@ #include "sizeof.h" -#define REALLOCF(p, n, T) REALLOCF_(p, n, typeas(T)) -#define REALLOCF_(p, n, T) \ +// reallocf_T - realloc free-on-error type-safe +#define reallocf_T(p, n, T) reallocf_T_(p, n, typeas(T)) +#define reallocf_T_(p, n, T) \ ({ \ _Generic(p, T *: (void)0); \ (T *){reallocarrayf_(p, n, sizeof(T))}; \ @@ -25,6 +26,7 @@ #define reallocarrayf_(p, n, size) reallocarrayf(p, (n) ?: 1, (size) ?: 1) +// reallocarrayf - realloc array free-on-error ATTR_ALLOC_SIZE(2, 3) ATTR_MALLOC(free) inline void *reallocarrayf(void *p, size_t nmemb, size_t size); diff --git a/lib/subordinateio.c b/lib/subordinateio.c index f9a845dd..54eb7641 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -962,7 +962,7 @@ static int append_uids(uid_t **uids, const char *owner, int n) return n; } - *uids = REALLOCF(*uids, n + 1, uid_t); + *uids = reallocf_T(*uids, n + 1, uid_t); if (!*uids) return -1; diff --git a/src/newusers.c b/src/newusers.c index bde90a3b..2e69f2c9 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -1196,9 +1196,9 @@ int main (int argc, char **argv) #ifdef USE_PAM /* keep the list of user/password for later update by PAM */ nusers++; - lines = REALLOCF(lines, nusers, intmax_t); - usernames = REALLOCF(usernames, nusers, char *); - passwords = REALLOCF(passwords, nusers, char *); + lines = reallocf_T(lines, nusers, intmax_t); + usernames = reallocf_T(usernames, nusers, char *); + passwords = reallocf_T(passwords, nusers, char *); if (lines == NULL || usernames == NULL || passwords == NULL) { fprintf(stderr, _("%s: line %jd: %s\n"), Prog, line, strerrno()); fail_exit (EXIT_FAILURE, process_selinux);