Use CALLOC() instead of its pattern

MALLOC() + memset() is simpler written as CALLOC().

Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-07-31 17:30:59 +02:00
committed by Iker Pedrosa
parent 24367027d6
commit 624bacfbd8
2 changed files with 2 additions and 4 deletions

View File

@@ -232,14 +232,13 @@ int find_new_uid(bool sys_user,
*/
/* Create an array to hold all of the discovered UIDs */
used_uids = MALLOC(uid_max + 1, bool);
used_uids = CALLOC(uid_max + 1, bool);
if (NULL == used_uids) {
fprintf (log_get_logfd(),
_("%s: failed to allocate memory: %s\n"),
log_get_progname(), strerror (errno));
return -1;
}
memset (used_uids, false, sizeof (bool) * (uid_max + 1));
/* First look for the lowest and highest value in the local database */
(void) pw_rewind ();

View File

@@ -23,12 +23,11 @@
struct group *gr;
int i;
gr = MALLOC(1, struct group);
gr = CALLOC(1, struct group);
if (NULL == gr) {
return NULL;
}
/* The libc might define other fields. They won't be copied. */
memset (gr, 0, sizeof *gr);
gr->gr_gid = grent->gr_gid;
/*@-mustfreeonly@*/
gr->gr_name = strdup (grent->gr_name);