From 49b9d3039dc63f9c7e0dec51997ac2dc7f1e8703 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" <ldv@altlinux.org> Date: Sun, 26 Apr 2020 11:12:59 +0000 Subject: pam_motd: cleanup calloc invocations Apply the following calloc invocation idiom: ptr = calloc(nmemb, sizeof(*ptr)); * modules/pam_motd/pam_motd.c (pam_split_string, try_to_display_directories_with_overrides): Cleanup calloc invocations. Fixes: f9c9c721 ("pam_motd: Support multiple motd paths specified, with filename overrides (#69)") --- modules/pam_motd/pam_motd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/pam_motd') diff --git a/modules/pam_motd/pam_motd.c b/modules/pam_motd/pam_motd.c index 49886d1a..df09b7d0 100644 --- a/modules/pam_motd/pam_motd.c +++ b/modules/pam_motd/pam_motd.c @@ -106,7 +106,7 @@ static int pam_split_string(const pam_handle_t *pamh, char *arg, char delim, arg_ptr = strchr(arg_ptr + sizeof(const char), delim); } - arg_split = calloc(num_strs, sizeof(char *)); + arg_split = calloc(num_strs, sizeof(*arg_split)); if (arg_split == NULL) { pam_syslog(pamh, LOG_CRIT, "failed to allocate string array"); goto out; @@ -201,11 +201,11 @@ static void try_to_display_directories_with_overrides(pam_handle_t *pamh, goto out; } - if ((dirscans = calloc(num_motd_dirs, sizeof(struct dirent **))) == NULL) { + if ((dirscans = calloc(num_motd_dirs, sizeof(*dirscans))) == NULL) { pam_syslog(pamh, LOG_CRIT, "failed to allocate dirent arrays"); goto out; } - if ((dirscans_sizes = calloc(num_motd_dirs, sizeof(int))) == NULL) { + if ((dirscans_sizes = calloc(num_motd_dirs, sizeof(*dirscans_sizes))) == NULL) { pam_syslog(pamh, LOG_CRIT, "failed to allocate dirent array sizes"); goto out; } @@ -228,7 +228,7 @@ static void try_to_display_directories_with_overrides(pam_handle_t *pamh, goto out; /* Allocate space for all file names found in the directories, including duplicates. */ - if ((dirnames_all = calloc(dirscans_size_total, sizeof(char *))) == NULL) { + if ((dirnames_all = calloc(dirscans_size_total, sizeof(*dirnames_all))) == NULL) { pam_syslog(pamh, LOG_CRIT, "failed to allocate dirname array"); goto out; } -- cgit v1.2.3