vbox: Drop needless g_new0(..., 0) in vbox_snapshot_conf.c

clang on Fedora started to complain about some calls to g_new0()
we're making in vbox_snapshot_conf.c. Specifically, we're passing
zero as number of elements to allocate. And while usually SA
tools are not clever, in this specific case clang is right.
There are three cases where such call is made, but all of them
later use VIR_EXPAND_N() to allocate more memory (if needed). But
VIR_EXPAND_N() accepts a variable set to NULL happily.

Therefore, just drop those three calls to g_new0(..., 0) and let
VIR_EXPAND_N() allocate memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Michal Privoznik 2024-04-12 17:45:16 +02:00
parent 812a146dfe
commit a4972778f9

View File

@ -460,8 +460,6 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardDisk *disk,
size_t i = 0; size_t i = 0;
size_t j = 0; size_t j = 0;
ret = g_new0(virVBoxSnapshotConfHardDisk *, 0);
for (i = 0; i < disk->nchildren; i++) { for (i = 0; i < disk->nchildren; i++) {
size_t tempSize = virVBoxSnapshotConfAllChildren(disk->children[i], &tempList); size_t tempSize = virVBoxSnapshotConfAllChildren(disk->children[i], &tempList);
VIR_EXPAND_N(ret, returnSize, tempSize); VIR_EXPAND_N(ret, returnSize, tempSize);
@ -1314,8 +1312,6 @@ virVBoxSnapshotConfRemoveFakeDisks(virVBoxSnapshotConfMachine *machine)
virVBoxSnapshotConfHardDisk **tempList = NULL; virVBoxSnapshotConfHardDisk **tempList = NULL;
virVBoxSnapshotConfHardDisk **diskList = NULL; virVBoxSnapshotConfHardDisk **diskList = NULL;
diskList = g_new0(virVBoxSnapshotConfHardDisk *, 0);
for (i = 0; i < machine->mediaRegistry->ndisks; i++) { for (i = 0; i < machine->mediaRegistry->ndisks; i++) {
tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i], &tempList); tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i], &tempList);
VIR_EXPAND_N(diskList, diskSize, tempSize); VIR_EXPAND_N(diskList, diskSize, tempSize);
@ -1364,8 +1360,6 @@ virVBoxSnapshotConfDiskIsInMediaRegistry(virVBoxSnapshotConfMachine *machine,
virVBoxSnapshotConfHardDisk **tempList = NULL; virVBoxSnapshotConfHardDisk **tempList = NULL;
virVBoxSnapshotConfHardDisk **diskList = NULL; virVBoxSnapshotConfHardDisk **diskList = NULL;
diskList = g_new0(virVBoxSnapshotConfHardDisk *, 0);
for (i = 0; i < machine->mediaRegistry->ndisks; i++) { for (i = 0; i < machine->mediaRegistry->ndisks; i++) {
tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i], &tempList); tempSize = virVBoxSnapshotConfAllChildren(machine->mediaRegistry->disks[i], &tempList);
VIR_EXPAND_N(diskList, diskSize, tempSize); VIR_EXPAND_N(diskList, diskSize, tempSize);