From bc4e3712a68b20c93fa0023fa465b0c55eda27db Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sat, 15 Nov 2025 22:08:15 +0100 Subject: [PATCH] lib/: Rename CALLOC() => calloc_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 --- lib/alloc/calloc.h | 7 ++++--- lib/find_new_gid.c | 2 +- lib/find_new_uid.c | 2 +- lib/groupio.c | 2 +- lib/groupmem.c | 2 +- lib/idmapping.c | 2 +- lib/pam_pass_non_interactive.c | 2 +- lib/pwmem.c | 2 +- lib/sgroupio.c | 2 +- lib/shadowmem.c | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/alloc/calloc.h b/lib/alloc/calloc.h index f9dc9ff6..f11298c0 100644 --- a/lib/alloc/calloc.h +++ b/lib/alloc/calloc.h @@ -14,14 +14,15 @@ #include "sizeof.h" -#define CALLOC(n, T) CALLOC_(n, typeas(T)) -#define CALLOC_(n, T) \ +// calloc_T - calloc type-safe +#define calloc_T(n, T) calloc_T_(n, typeas(T)) +#define calloc_T_(n, T) \ ({ \ (T *){calloc(n, sizeof(T))}; \ }) -#define XCALLOC(n, T) exit_if_null(CALLOC(n, T)) +#define XCALLOC(n, T) exit_if_null(calloc_T(n, T)) #endif // include guard diff --git a/lib/find_new_gid.c b/lib/find_new_gid.c index 0d74945c..dfcc9143 100644 --- a/lib/find_new_gid.c +++ b/lib/find_new_gid.c @@ -235,7 +235,7 @@ int find_new_gid (bool sys_group, */ /* Create an array to hold all of the discovered GIDs */ - used_gids = CALLOC (gid_max + 1, bool); + used_gids = calloc_T(gid_max + 1, bool); if (NULL == used_gids) { fprintf (log_get_logfd(), _("%s: failed to allocate memory: %s\n"), diff --git a/lib/find_new_uid.c b/lib/find_new_uid.c index 4cce6813..3cafef60 100644 --- a/lib/find_new_uid.c +++ b/lib/find_new_uid.c @@ -234,7 +234,7 @@ int find_new_uid(bool sys_user, */ /* Create an array to hold all of the discovered UIDs */ - used_uids = CALLOC(uid_max + 1, bool); + used_uids = calloc_T(uid_max + 1, bool); if (NULL == used_uids) { fprintf (log_get_logfd(), _("%s: failed to allocate memory: %s\n"), diff --git a/lib/groupio.c b/lib/groupio.c index e1d984de..f62a9bbd 100644 --- a/lib/groupio.c +++ b/lib/groupio.c @@ -344,7 +344,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries ( members++; } } - new_members = CALLOC (members + 1, char *); + new_members = calloc_T(members + 1, char *); if (NULL == new_members) { free(new_line); return NULL; diff --git a/lib/groupmem.c b/lib/groupmem.c index c1189f3c..1ebe2f9b 100644 --- a/lib/groupmem.c +++ b/lib/groupmem.c @@ -25,7 +25,7 @@ struct group *gr; int i; - gr = CALLOC(1, struct group); + gr = calloc_T(1, struct group); if (NULL == gr) { return NULL; } diff --git a/lib/idmapping.c b/lib/idmapping.c index 485195ba..88a0c00e 100644 --- a/lib/idmapping.c +++ b/lib/idmapping.c @@ -47,7 +47,7 @@ get_map_ranges(int ranges, int argc, char **argv) return NULL; } - mappings = CALLOC(ranges, struct map_range); + mappings = calloc_T(ranges, struct map_range); if (!mappings) { fprintf(log_get_logfd(), _( "%s: Memory allocation failure\n"), log_get_progname()); diff --git a/lib/pam_pass_non_interactive.c b/lib/pam_pass_non_interactive.c index 411a5f15..054077f3 100644 --- a/lib/pam_pass_non_interactive.c +++ b/lib/pam_pass_non_interactive.c @@ -49,7 +49,7 @@ static int ni_conv (int num_msg, return PAM_CONV_ERR; } - responses = CALLOC (num_msg, struct pam_response); + responses = calloc_T(num_msg, struct pam_response); if (NULL == responses) { return PAM_CONV_ERR; } diff --git a/lib/pwmem.c b/lib/pwmem.c index e0e0542f..b86be4b3 100644 --- a/lib/pwmem.c +++ b/lib/pwmem.c @@ -25,7 +25,7 @@ { struct passwd *pw; - pw = CALLOC (1, struct passwd); + pw = calloc_T(1, struct passwd); if (NULL == pw) { return NULL; } diff --git a/lib/sgroupio.c b/lib/sgroupio.c index 09e6fbba..ad3adc34 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -34,7 +34,7 @@ struct sgrp *sg; int i; - sg = CALLOC (1, struct sgrp); + sg = calloc_T(1, struct sgrp); if (NULL == sg) { return NULL; } diff --git a/lib/shadowmem.c b/lib/shadowmem.c index bd2df380..1a7b9a2a 100644 --- a/lib/shadowmem.c +++ b/lib/shadowmem.c @@ -26,7 +26,7 @@ { struct spwd *sp; - sp = CALLOC (1, struct spwd); + sp = calloc_T(1, struct spwd); if (NULL == sp) { return NULL; }