summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-04-26 11:12:59 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-04-26 11:12:59 +0000
commit49b9d3039dc63f9c7e0dec51997ac2dc7f1e8703 (patch)
treea6b8623130e967fc6cbf342804f71e01f7f83ad8
parentb77aa28f46596773110e842d79b65d3fdce9ed22 (diff)
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)")
-rw-r--r--modules/pam_motd/pam_motd.c8
1 files changed, 4 insertions, 4 deletions
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;
}