Use calloc(3) instead of its pattern
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
1aa22c1467
commit
a578617cc0
@ -21,12 +21,11 @@
|
|||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
pw = (struct passwd *) malloc (sizeof *pw);
|
pw = (struct passwd *) calloc (1, sizeof *pw);
|
||||||
if (NULL == pw) {
|
if (NULL == pw) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* The libc might define other fields. They won't be copied. */
|
/* The libc might define other fields. They won't be copied. */
|
||||||
memset (pw, 0, sizeof *pw);
|
|
||||||
pw->pw_uid = pwent->pw_uid;
|
pw->pw_uid = pwent->pw_uid;
|
||||||
pw->pw_gid = pwent->pw_gid;
|
pw->pw_gid = pwent->pw_gid;
|
||||||
/*@-mustfreeonly@*/
|
/*@-mustfreeonly@*/
|
||||||
|
@ -25,13 +25,12 @@
|
|||||||
struct sgrp *sg;
|
struct sgrp *sg;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sg = (struct sgrp *) malloc (sizeof *sg);
|
sg = (struct sgrp *) calloc (1, sizeof *sg);
|
||||||
if (NULL == sg) {
|
if (NULL == sg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Do the same as the other _dup function, even if we know the
|
/* Do the same as the other _dup function, even if we know the
|
||||||
* structure. */
|
* structure. */
|
||||||
memset (sg, 0, sizeof *sg);
|
|
||||||
/*@-mustfreeonly@*/
|
/*@-mustfreeonly@*/
|
||||||
sg->sg_name = strdup (sgent->sg_name);
|
sg->sg_name = strdup (sgent->sg_name);
|
||||||
/*@=mustfreeonly@*/
|
/*@=mustfreeonly@*/
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
{
|
{
|
||||||
struct spwd *sp;
|
struct spwd *sp;
|
||||||
|
|
||||||
sp = (struct spwd *) malloc (sizeof *sp);
|
sp = (struct spwd *) calloc (1, sizeof *sp);
|
||||||
if (NULL == sp) {
|
if (NULL == sp) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* The libc might define other fields. They won't be copied. */
|
/* The libc might define other fields. They won't be copied. */
|
||||||
memset (sp, 0, sizeof *sp);
|
|
||||||
sp->sp_lstchg = spent->sp_lstchg;
|
sp->sp_lstchg = spent->sp_lstchg;
|
||||||
sp->sp_min = spent->sp_min;
|
sp->sp_min = spent->sp_min;
|
||||||
sp->sp_max = spent->sp_max;
|
sp->sp_max = spent->sp_max;
|
||||||
|
@ -231,14 +231,13 @@ int find_new_gid (bool sys_group,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Create an array to hold all of the discovered GIDs */
|
/* Create an array to hold all of the discovered GIDs */
|
||||||
used_gids = malloc (sizeof (bool) * (gid_max +1));
|
used_gids = calloc (gid_max + 1, sizeof (bool));
|
||||||
if (NULL == used_gids) {
|
if (NULL == used_gids) {
|
||||||
fprintf (log_get_logfd(),
|
fprintf (log_get_logfd(),
|
||||||
_("%s: failed to allocate memory: %s\n"),
|
_("%s: failed to allocate memory: %s\n"),
|
||||||
log_get_progname(), strerror (errno));
|
log_get_progname(), strerror (errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset (used_gids, false, sizeof (bool) * (gid_max + 1));
|
|
||||||
|
|
||||||
/* First look for the lowest and highest value in the local database */
|
/* First look for the lowest and highest value in the local database */
|
||||||
(void) gr_rewind ();
|
(void) gr_rewind ();
|
||||||
|
Loading…
Reference in New Issue
Block a user