1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

gcc-fanalyzer: use zeroed memory

Analyzer here was rather confused about possiblity of loosing previously
assigned device pointers - fixed by passing zero initialize memory
before first assign.
This commit is contained in:
Zdenek Kabelac 2021-09-18 21:01:48 +02:00
parent 5126ac7c3a
commit 93d565eda9
2 changed files with 3 additions and 3 deletions

View File

@ -2069,7 +2069,7 @@ static void _restart_dmeventd(void)
++count;
}
if (!(_initial_registrations = malloc(sizeof(char*) * (count + 1)))) {
if (!(_initial_registrations = zalloc(sizeof(char*) * (count + 1)))) {
fprintf(stderr, "Memory allocation registration failed.\n");
goto bad;
}

View File

@ -194,7 +194,7 @@ static int _get_other_devs(struct cmd_context *cmd, struct dm_list *new_devs, st
while ((dev = dev_iter_get(cmd, iter))) {
if (_get_device_list(new_devs, dev))
continue;
if (!(devl = malloc(sizeof(*devl)))) {
if (!(devl = zalloc(sizeof(*devl)))) {
r = 0;
goto_bad;
}
@ -278,7 +278,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
if (!(devl = malloc(sizeof(*devl))))
if (!(devl = zalloc(sizeof(*devl))))
goto_out;
devl->dev = dev;