if (VIR_ALLOC_N(firmwares, 2) < 0)
return ret;
- if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0)
- goto cleanup;
+ firmwares[0] = g_new0(virFirmware, 1);
+ firmwares[1] = g_new0(virFirmware, 1);
+
firmwares[0]->name = g_strdup("/usr/lib/xen/boot/hvmloader");
firmwares[1]->name = g_strdup("/usr/lib/xen/boot/ovmf.bin");
virDomainCapsStringValuesPtr firmwares = NULL;
int ret = -1;
- if (VIR_ALLOC(firmwares) < 0)
- return -1;
+ firmwares = g_new0(virDomainCapsStringValues, 1);
if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0)
goto cleanup;
{
virNodeDeviceDefPtr def = NULL;
- if (VIR_ALLOC(def) != 0 || VIR_ALLOC(def->caps) != 0) {
- virNodeDeviceDefFree(def);
- return NULL;
- }
-
+ def = g_new0(virNodeDeviceDef, 1);
+ def->caps = g_new0(virNodeDevCapsDef, 1);
def->name = g_strdup("computer");
return def;
virNodeDeviceDefPtr def = NULL;
virNodeDevCapPCIDevPtr pci_dev;
- if (VIR_ALLOC(def) != 0 || VIR_ALLOC(def->caps) != 0) {
- virNodeDeviceDefFree(def);
- return NULL;
- }
+ def = g_new0(virNodeDeviceDef, 1);
+ def->caps = g_new0(virNodeDevCapsDef, 1);
def->name = g_strdup("pci_0000_00_02_0");
def->parent = g_strdup("computer");
nodedevTestDriverInit(void)
{
int ret = -1;
- if (VIR_ALLOC(driver) < 0)
- return -1;
+ driver = g_new0(virNodeDeviceDriverState, 1);
driver->lockFD = -1;
if (virMutexInit(&driver->lock) < 0 ||
virNWFilterRuleInstPtr ruleinst;
int ret = -1;
- if (VIR_ALLOC(ruleinst) < 0)
- goto cleanup;
+ ruleinst = g_new0(virNWFilterRuleInst, 1);
ruleinst->chainSuffix = def->chainsuffix;
ruleinst->chainPriority = def->chainPriority;
srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
if (src->auth) {
- if (VIR_ALLOC(srcpriv->secinfo) < 0)
- return -1;
+ srcpriv->secinfo = g_new0(qemuDomainSecretInfo, 1);
srcpriv->secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
srcpriv->secinfo->s.aes.username = g_strdup(src->auth->username);
}
if (src->encryption) {
- if (VIR_ALLOC(srcpriv->encinfo) < 0)
- return -1;
+ srcpriv->encinfo = g_new0(qemuDomainSecretInfo, 1);
srcpriv->encinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
srcpriv->encinfo->s.aes.alias = g_strdup_printf("%s-encalias",
return NULL;
}
- if (VIR_ALLOC(diskdef) < 0)
- return NULL;
+ diskdef = g_new0(virDomainSnapshotDiskDef, 1);
if (virDomainSnapshotDiskDefParseXML(node, ctxt, diskdef,
VIR_DOMAIN_DEF_PARSE_STATUS,
prefix = g_strdup_printf("%s/qemuhotplugtestcpus/%s", abs_srcdir, test);
- if (VIR_ALLOC(data) < 0)
- goto error;
+ data = g_new0(struct testQemuHotplugCpuData, 1);
data->modern = modern;
!(expectedBlockDevices = virHashCreate(32, virHashValueFree)))
goto cleanup;
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(struct qemuDomainDiskInfo, 1);
if (virHashAddEntry(expectedBlockDevices, "virtio-disk0", info) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
goto cleanup;
}
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(struct qemuDomainDiskInfo, 1);
if (virHashAddEntry(expectedBlockDevices, "virtio-disk1", info) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
goto cleanup;
}
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(struct qemuDomainDiskInfo, 1);
info->removable = true;
info->tray = true;
goto cleanup;
}
- if (VIR_ALLOC(info) < 0)
- goto cleanup;
+ info = g_new0(struct qemuDomainDiskInfo, 1);
info->removable = true;
info->tray = true;
{
qemuMonitorTestItemPtr item;
- if (VIR_ALLOC(item) < 0)
- goto error;
+ item = g_new0(qemuMonitorTestItem, 1);
item->identifier = g_strdup(identifier);
item->cb = cb;
{
struct qemuMonitorTestHandlerData *data;
- if (VIR_ALLOC(data) < 0)
- return -1;
+ data = g_new0(struct qemuMonitorTestHandlerData, 1);
data->command_name = g_strdup(command_name);
data->response = g_strdup(response);
{
struct qemuMonitorTestHandlerData *data;
- if (VIR_ALLOC(data) < 0)
- return -1;
+ data = g_new0(struct qemuMonitorTestHandlerData, 1);
data->response = g_strdup(response);
data->cmderr = g_strdup(cmderr);
va_start(args, response);
- if (VIR_ALLOC(data) < 0)
- goto error;
+ data = g_new0(struct qemuMonitorTestHandlerData, 1);
data->command_name = g_strdup(cmdname);
data->response = g_strdup(response);
{
struct qemuMonitorTestHandlerData *data;
- if (VIR_ALLOC(data) < 0)
- goto error;
+ data = g_new0(struct qemuMonitorTestHandlerData, 1);
data->command_name = g_strdup(cmdname);
data->response = g_strdup(response);
cmdname,
qemuMonitorTestProcessCommandWithArgStr,
data, qemuMonitorTestHandlerDataFree);
-
- error:
- qemuMonitorTestHandlerDataFree(data);
- return -1;
}
char *path = NULL;
char *tmpdir_template = NULL;
- if (VIR_ALLOC(test) < 0)
- goto error;
+ test = g_new0(qemuMonitorTest, 1);
if (virMutexInit(&test->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
abort();
}
- if (VIR_ALLOC(val) < 0)
- return -1;
+ val = g_new0(uint32_t, 1);
*val = (gid << 16) + uid;
return real_selabel_open(backend, opts, nopts);
/* struct selabel_handle is opaque; fake it */
- if (VIR_ALLOC(fake_handle) < 0)
- return NULL;
+ fake_handle = g_new0(char, 1);
return (struct selabel_handle *)fake_handle;
}
if (VIR_ALLOC_N(def->seclabels, 1) < 0)
goto error;
- if (VIR_ALLOC(secdef) < 0)
- goto error;
+ secdef = g_new0(virSecurityLabelDef, 1);
secdef->model = g_strdup("selinux");
goto cleanup;
}
- if (VIR_ALLOC(mgr) < 0)
- goto cleanup;
+ mgr = g_new0(virHostdevManager, 1);
if ((mgr->activePCIHostdevs = virPCIDeviceListNew()) == NULL)
goto cleanup;
if ((mgr->activeUSBHostdevs = virUSBDeviceListNew()) == NULL)
{
struct testClientPriv *priv;
- if (VIR_ALLOC(priv) < 0)
- return NULL;
+ priv = g_new0(struct testClientPriv, 1);
priv->magic = 1729;
err.domain = VIR_FROM_RPC;
err.level = VIR_ERR_ERROR;
- if (VIR_ALLOC(err.message) < 0 ||
- VIR_ALLOC(err.str1) < 0 ||
- VIR_ALLOC(err.str2) < 0 ||
- VIR_ALLOC(err.str3) < 0)
- goto cleanup;
+ err.message = g_new0(char *, 1);
+ err.str1 = g_new0(char *, 1);
+ err.str2 = g_new0(char *, 1);
+ err.str3 = g_new0(char *, 1);
*err.message = g_strdup("Hello World");
*err.str1 = g_strdup("One");
{
char *dummy;
- if (VIR_ALLOC(dummy) < 0)
- return NULL;
+ dummy = g_new0(char, 1);
return dummy;
}
goto cleanup;
}
- if (!list &&
- VIR_ALLOC(list) < 0)
- goto cleanup;
+ if (!list)
+ list = g_new0(char *, 1);
if (!(got = virStringListJoin((const char **)list, data->delim))) {
VIR_DEBUG("Got no result");