On Mon, Aug 14, 2023 at 9:41 AM Christian Göttsche <cgzones@xxxxxxxxxxxxxx> wrote: > > Merge malloc(3) plus memset(3) call into calloc(3). > > Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> Acked-by: James Carter <jwcart2@xxxxxxxxx> > --- > libselinux/src/label_file.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c > index 5ac23e1f..b9be1c9d 100644 > --- a/libselinux/src/label_file.c > +++ b/libselinux/src/label_file.c > @@ -716,10 +716,9 @@ static int selabel_subs_init(const char *path, struct selabel_digest *digest, > if (! *dst) > continue; > > - sub = malloc(sizeof(*sub)); > + sub = calloc(1, sizeof(*sub)); > if (! sub) > goto err; > - memset(sub, 0, sizeof(*sub)); > > sub->src = strdup(src); > if (! sub->src) > @@ -1357,10 +1356,9 @@ int selabel_file_init(struct selabel_handle *rec, > { > struct saved_data *data; > > - data = (struct saved_data *)malloc(sizeof(*data)); > + data = (struct saved_data *)calloc(1, sizeof(*data)); > if (!data) > return -1; > - memset(data, 0, sizeof(*data)); > > rec->data = data; > rec->func_close = &closef; > -- > 2.40.1 >