mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 22:05:47 +00:00
Adapt to VIR_ALLOC and virAsprintf in src/interface/*
This commit is contained in:
parent
1f2bf4833b
commit
d89f8056a8
@ -65,10 +65,8 @@ netcfGetMinimalDefForDevice(struct netcf_if *iface)
|
|||||||
virInterfaceDef *def;
|
virInterfaceDef *def;
|
||||||
|
|
||||||
/* Allocate our interface definition structure */
|
/* Allocate our interface definition structure */
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_STRDUP(def->name, ncf_if_name(iface)) < 0)
|
if (VIR_STRDUP(def->name, ncf_if_name(iface)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -157,10 +155,7 @@ static virDrvOpenStatus netcfInterfaceOpen(virConnectPtr conn,
|
|||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (VIR_ALLOC(driverState) < 0)
|
if (VIR_ALLOC(driverState) < 0)
|
||||||
{
|
|
||||||
virReportOOMError();
|
|
||||||
goto alloc_error;
|
goto alloc_error;
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize non-0 stuff in driverState */
|
/* initialize non-0 stuff in driverState */
|
||||||
if (virMutexInit(&driverState->lock) < 0)
|
if (virMutexInit(&driverState->lock) < 0)
|
||||||
@ -239,10 +234,8 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(names, count) < 0) {
|
if (VIR_ALLOC_N(names, count) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
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;
|
||||||
@ -332,10 +325,8 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(allnames, count) < 0) {
|
if (VIR_ALLOC_N(allnames, count) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
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;
|
||||||
@ -519,10 +510,8 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(names, count) < 0) {
|
if (VIR_ALLOC_N(names, count) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if ((count = ncf_list_interfaces(driver->netcf, count, names,
|
if ((count = ncf_list_interfaces(driver->netcf, count, names,
|
||||||
NETCF_IFACE_ACTIVE |
|
NETCF_IFACE_ACTIVE |
|
||||||
@ -536,12 +525,8 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ifaces) {
|
if (ifaces && VIR_ALLOC_N(tmp_iface_objs, count + 1) < 0)
|
||||||
if (VIR_ALLOC_N(tmp_iface_objs, count + 1) < 0) {
|
goto cleanup;
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
virInterfaceDefPtr def;
|
virInterfaceDefPtr def;
|
||||||
|
@ -73,10 +73,8 @@ udevGetMinimalDefForDevice(struct udev_device *dev)
|
|||||||
virInterfaceDef *def;
|
virInterfaceDef *def;
|
||||||
|
|
||||||
/* Allocate our interface definition structure */
|
/* Allocate our interface definition structure */
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_STRDUP(def->name, udev_device_get_sysname(dev)) < 0)
|
if (VIR_STRDUP(def->name, udev_device_get_sysname(dev)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -141,10 +139,8 @@ udevInterfaceOpen(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (VIR_ALLOC(driverState) < 0) {
|
if (VIR_ALLOC(driverState) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
driverState->udev = udev_new();
|
driverState->udev = udev_new();
|
||||||
if (!driverState->udev) {
|
if (!driverState->udev) {
|
||||||
@ -403,12 +399,9 @@ 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) {
|
if (ifaces && VIR_ALLOC_N(ifaces_list, count + 1) < 0) {
|
||||||
if (VIR_ALLOC_N(ifaces_list, count + 1) < 0) {
|
ret = -1;
|
||||||
virReportOOMError();
|
goto cleanup;
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a list we can walk */
|
/* Get a list we can walk */
|
||||||
@ -815,10 +808,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) {
|
if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
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++) {
|
||||||
@ -918,10 +909,8 @@ udevGetIfaceDefBridge(struct udev *udev,
|
|||||||
|
|
||||||
/* Members of the bridge */
|
/* Members of the bridge */
|
||||||
if (virAsprintf(&member_path, "%s/%s",
|
if (virAsprintf(&member_path, "%s/%s",
|
||||||
udev_device_get_syspath(dev), "brif") < 0) {
|
udev_device_get_syspath(dev), "brif") < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
/* Get each member of the bridge */
|
/* Get each member of the bridge */
|
||||||
member_count = scandir(member_path, &member_list,
|
member_count = scandir(member_path, &member_list,
|
||||||
@ -938,10 +927,8 @@ 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) {
|
if (VIR_ALLOC_N(ifacedef->data.bridge.itf, member_count) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
ifacedef->data.bridge.nbItf = member_count;
|
ifacedef->data.bridge.nbItf = member_count;
|
||||||
|
|
||||||
/* Get the interface defintions for each member of the bridge */
|
/* Get the interface defintions for each member of the bridge */
|
||||||
@ -1016,10 +1003,8 @@ 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) {
|
if (VIR_ALLOC(ifacedef) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user