mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
interface: use g_new0 instead of VIR_ALLOC*
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
535d78630f
commit
98906dbcee
@ -247,8 +247,7 @@ netcfGetMinimalDefForDevice(struct netcf_if *iface)
|
|||||||
virInterfaceDef *def;
|
virInterfaceDef *def;
|
||||||
|
|
||||||
/* Allocate our interface definition structure */
|
/* Allocate our interface definition structure */
|
||||||
if (VIR_ALLOC(def) < 0)
|
def = g_new0(virInterfaceDef, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
def->name = g_strdup(ncf_if_name(iface));
|
def->name = g_strdup(ncf_if_name(iface));
|
||||||
def->mac = g_strdup(ncf_if_mac_string(iface));
|
def->mac = g_strdup(ncf_if_mac_string(iface));
|
||||||
@ -375,8 +374,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(names, count) < 0)
|
names = g_new0(char *, count);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if ((count = ncf_list_interfaces(driver->netcf, count, names, status)) < 0) {
|
if ((count = ncf_list_interfaces(driver->netcf, count, names, status)) < 0) {
|
||||||
const char *errmsg, *details;
|
const char *errmsg, *details;
|
||||||
@ -465,8 +463,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(allnames, count) < 0)
|
allnames = g_new0(char *, count);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if ((count = ncf_list_interfaces(driver->netcf, count, allnames, status)) < 0) {
|
if ((count = ncf_list_interfaces(driver->netcf, count, allnames, status)) < 0) {
|
||||||
const char *errmsg, *details;
|
const char *errmsg, *details;
|
||||||
@ -651,8 +648,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(names, count) < 0)
|
names = g_new0(char *, count);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if ((count = ncf_list_interfaces(driver->netcf, count,
|
if ((count = ncf_list_interfaces(driver->netcf, count,
|
||||||
names, ncf_flags)) < 0) {
|
names, ncf_flags)) < 0) {
|
||||||
@ -666,8 +662,8 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ifaces && VIR_ALLOC_N(tmp_iface_objs, count + 1) < 0)
|
if (ifaces)
|
||||||
goto cleanup;
|
tmp_iface_objs = g_new0(virInterfacePtr, count + 1);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
virInterfaceDefPtr def;
|
virInterfaceDefPtr def;
|
||||||
|
@ -86,8 +86,7 @@ udevGetMinimalDefForDevice(struct udev_device *dev)
|
|||||||
virInterfaceDef *def;
|
virInterfaceDef *def;
|
||||||
|
|
||||||
/* Allocate our interface definition structure */
|
/* Allocate our interface definition structure */
|
||||||
if (VIR_ALLOC(def) < 0)
|
def = g_new0(virInterfaceDef, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
def->name = g_strdup(udev_device_get_sysname(dev));
|
def->name = g_strdup(udev_device_get_sysname(dev));
|
||||||
def->mac = g_strdup(udev_device_get_sysattr_value(dev, "address"));
|
def->mac = g_strdup(udev_device_get_sysattr_value(dev, "address"));
|
||||||
@ -352,10 +351,8 @@ udevConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If we're asked for the ifaces then alloc up memory */
|
/* If we're asked for the ifaces then alloc up memory */
|
||||||
if (ifaces && VIR_ALLOC_N(ifaces_list, count + 1) < 0) {
|
if (ifaces)
|
||||||
ret = -1;
|
ifaces_list = g_new0(virInterfacePtr, count + 1);
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get a list we can walk */
|
/* Get a list we can walk */
|
||||||
devices = udev_enumerate_get_list_entry(enumerate);
|
devices = udev_enumerate_get_list_entry(enumerate);
|
||||||
@ -758,8 +755,8 @@ udevGetIfaceDefBond(struct udev *udev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate our list of slave devices */
|
/* Allocate our list of slave devices */
|
||||||
if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0)
|
ifacedef->data.bond.itf = g_new0(struct _virInterfaceDef *,
|
||||||
goto error;
|
slave_count);
|
||||||
ifacedef->data.bond.nbItf = slave_count;
|
ifacedef->data.bond.nbItf = slave_count;
|
||||||
|
|
||||||
for (i = 0; i < slave_count; i++) {
|
for (i = 0; i < slave_count; i++) {
|
||||||
@ -873,8 +870,7 @@ udevGetIfaceDefBridge(struct udev *udev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate our list of member devices */
|
/* Allocate our list of member devices */
|
||||||
if (VIR_ALLOC_N(ifacedef->data.bridge.itf, member_count) < 0)
|
ifacedef->data.bridge.itf = g_new0(struct _virInterfaceDef *, member_count);
|
||||||
goto error;
|
|
||||||
ifacedef->data.bridge.nbItf = member_count;
|
ifacedef->data.bridge.nbItf = member_count;
|
||||||
|
|
||||||
/* Get the interface definitions for each member of the bridge */
|
/* Get the interface definitions for each member of the bridge */
|
||||||
@ -976,8 +972,7 @@ udevGetIfaceDef(struct udev *udev, const char *name)
|
|||||||
const char *devtype;
|
const char *devtype;
|
||||||
|
|
||||||
/* Allocate our interface definition structure */
|
/* Allocate our interface definition structure */
|
||||||
if (VIR_ALLOC(ifacedef) < 0)
|
ifacedef = g_new0(virInterfaceDef, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Clear our structure and set safe defaults */
|
/* Clear our structure and set safe defaults */
|
||||||
ifacedef->startmode = VIR_INTERFACE_START_UNSPECIFIED;
|
ifacedef->startmode = VIR_INTERFACE_START_UNSPECIFIED;
|
||||||
@ -1158,8 +1153,7 @@ udevStateInitialize(bool privileged,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
driver = g_new0(struct udev_iface_driver, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user