node_device: use g_new0 instead of VIR_ALLOC*

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Ján Tomko 2020-09-23 22:04:41 +02:00
parent 3013c4659d
commit 1725d0bfbc

View File

@ -413,13 +413,11 @@ udevProcessPCI(struct udev_device *device,
goto cleanup; goto cleanup;
if (virPCIDeviceIsPCIExpress(pciDev) > 0) { if (virPCIDeviceIsPCIExpress(pciDev) > 0) {
if (VIR_ALLOC(pci_express) < 0) pci_express = g_new0(virPCIEDeviceInfo, 1);
goto cleanup;
if (virPCIDeviceHasPCIExpressLink(pciDev) > 0) { if (virPCIDeviceHasPCIExpressLink(pciDev) > 0) {
if (VIR_ALLOC(pci_express->link_cap) < 0 || pci_express->link_cap = g_new0(virPCIELink, 1);
VIR_ALLOC(pci_express->link_sta) < 0) pci_express->link_sta = g_new0(virPCIELink, 1);
goto cleanup;
if (virPCIDeviceGetLinkCapSta(pciDev, if (virPCIDeviceGetLinkCapSta(pciDev,
&pci_express->link_cap->port, &pci_express->link_cap->port,
@ -1159,8 +1157,7 @@ udevGetDeviceNodes(struct udev_device *device,
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device))
n++; n++;
if (VIR_ALLOC_N(def->devlinks, n + 1) < 0) def->devlinks = g_new0(char *, n + 1);
return -1;
n = 0; n = 0;
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) { udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
@ -1371,16 +1368,14 @@ udevAddOneDevice(struct udev_device *device)
bool new_device = true; bool new_device = true;
int ret = -1; int ret = -1;
if (VIR_ALLOC(def) != 0) def = g_new0(virNodeDeviceDef, 1);
goto cleanup;
def->sysfs_path = g_strdup(udev_device_get_syspath(device)); def->sysfs_path = g_strdup(udev_device_get_syspath(device));
if (udevGetStringProperty(device, "DRIVER", &def->driver) < 0) if (udevGetStringProperty(device, "DRIVER", &def->driver) < 0)
goto cleanup; goto cleanup;
if (VIR_ALLOC(def->caps) != 0) def->caps = g_new0(virNodeDevCapsDef, 1);
goto cleanup;
if (udevGetDeviceType(device, &def->caps->data.type) != 0) if (udevGetDeviceType(device, &def->caps->data.type) != 0)
goto cleanup; goto cleanup;
@ -1788,13 +1783,10 @@ udevSetupSystemDev(void)
virNodeDeviceObjPtr obj = NULL; virNodeDeviceObjPtr obj = NULL;
int ret = -1; int ret = -1;
if (VIR_ALLOC(def) < 0) def = g_new0(virNodeDeviceDef, 1);
return -1;
def->name = g_strdup("computer"); def->name = g_strdup("computer");
def->caps = g_new0(virNodeDevCapsDef, 1);
if (VIR_ALLOC(def->caps) != 0)
goto cleanup;
#if defined(__x86_64__) || defined(__i386__) || defined(__amd64__) #if defined(__x86_64__) || defined(__i386__) || defined(__amd64__)
udevGetDMIData(&def->caps->data.system); udevGetDMIData(&def->caps->data.system);
@ -1882,8 +1874,7 @@ nodeStateInitialize(bool privileged,
return -1; return -1;
} }
if (VIR_ALLOC(driver) < 0) driver = g_new0(virNodeDeviceDriverState, 1);
return VIR_DRV_STATE_INIT_ERROR;
driver->lockFD = -1; driver->lockFD = -1;
if (virMutexInit(&driver->lock) < 0) { if (virMutexInit(&driver->lock) < 0) {