virInterfaceDef *def;
/* Allocate our interface definition structure */
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virInterfaceDef, 1);
def->name = g_strdup(ncf_if_name(iface));
def->mac = g_strdup(ncf_if_mac_string(iface));
goto cleanup;
}
- if (VIR_ALLOC_N(names, count) < 0)
- goto cleanup;
+ names = g_new0(char *, count);
if ((count = ncf_list_interfaces(driver->netcf, count, names, status)) < 0) {
const char *errmsg, *details;
goto cleanup;
}
- if (VIR_ALLOC_N(allnames, count) < 0)
- goto cleanup;
+ allnames = g_new0(char *, count);
if ((count = ncf_list_interfaces(driver->netcf, count, allnames, status)) < 0) {
const char *errmsg, *details;
goto cleanup;
}
- if (VIR_ALLOC_N(names, count) < 0)
- goto cleanup;
+ names = g_new0(char *, count);
if ((count = ncf_list_interfaces(driver->netcf, count,
names, ncf_flags)) < 0) {
goto cleanup;
}
- if (ifaces && VIR_ALLOC_N(tmp_iface_objs, count + 1) < 0)
- goto cleanup;
+ if (ifaces)
+ tmp_iface_objs = g_new0(virInterfacePtr, count + 1);
for (i = 0; i < count; i++) {
virInterfaceDefPtr def;
virInterfaceDef *def;
/* Allocate our interface definition structure */
- if (VIR_ALLOC(def) < 0)
- return NULL;
+ def = g_new0(virInterfaceDef, 1);
def->name = g_strdup(udev_device_get_sysname(dev));
def->mac = g_strdup(udev_device_get_sysattr_value(dev, "address"));
}
/* If we're asked for the ifaces then alloc up memory */
- if (ifaces && VIR_ALLOC_N(ifaces_list, count + 1) < 0) {
- ret = -1;
- goto cleanup;
- }
+ if (ifaces)
+ ifaces_list = g_new0(virInterfacePtr, count + 1);
/* Get a list we can walk */
devices = udev_enumerate_get_list_entry(enumerate);
}
/* Allocate our list of slave devices */
- if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0)
- goto error;
+ ifacedef->data.bond.itf = g_new0(struct _virInterfaceDef *,
+ slave_count);
ifacedef->data.bond.nbItf = slave_count;
for (i = 0; i < slave_count; i++) {
}
/* Allocate our list of member devices */
- if (VIR_ALLOC_N(ifacedef->data.bridge.itf, member_count) < 0)
- goto error;
+ ifacedef->data.bridge.itf = g_new0(struct _virInterfaceDef *, member_count);
ifacedef->data.bridge.nbItf = member_count;
/* Get the interface definitions for each member of the bridge */
const char *devtype;
/* Allocate our interface definition structure */
- if (VIR_ALLOC(ifacedef) < 0)
- return NULL;
+ ifacedef = g_new0(virInterfaceDef, 1);
/* Clear our structure and set safe defaults */
ifacedef->startmode = VIR_INTERFACE_START_UNSPECIFIED;
return -1;
}
- if (VIR_ALLOC(driver) < 0)
- goto cleanup;
+ driver = g_new0(struct udev_iface_driver, 1);
driver->lockFD = -1;