unsigned int fakeflags G_GNUC_UNUSED)
{
VIR_FREE(*ifname);
- if (VIR_STRDUP(*ifname, "vnet0") < 0)
- return -1;
+ *ifname = g_strdup("vnet0");
return 0;
}
{
char *fakename;
- if (VIR_STRDUP(fakename, "faketapdev") < 0)
- return NULL;
+ fakename = g_strdup("faketapdev");
return fakename;
}
goto cleanup;
}
VIR_FREE(outbuf);
- if (VIR_STRDUP(outbuf, "should not be leaked") < 0) {
- puts("test framework failure");
- goto cleanup;
- }
+ outbuf = g_strdup("should not be leaked");
virCommandSetErrorBuffer(cmd, &errbuf);
if (errbuf != NULL) {
if (!(testMon = qemuMonitorTestNewFromFile(json, driver.xmlopt, true)))
goto error;
- if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, "host") < 0)
+ if (VIR_ALLOC(cpu) < 0)
goto cleanup;
+ cpu->model = g_strdup("host");
+
if (ARCH_IS_S390(data->arch))
fail_no_props = false;
va_start(list, values);
while ((str = va_arg(list, const char *))) {
- if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0 ||
- VIR_STRDUP(values->values[values->nvalues], str) < 0) {
+ if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0) {
ret = -1;
break;
}
+ values->values[values->nvalues] = g_strdup(str);
values->nvalues++;
}
va_end(list);
if (machine) {
VIR_FREE(domCaps->machine);
- if (VIR_STRDUP(domCaps->machine,
- virQEMUCapsGetCanonicalMachine(qemuCaps, machine)) < 0)
- goto cleanup;
+ domCaps->machine = g_strdup(virQEMUCapsGetCanonicalMachine(qemuCaps, machine));
}
if (!domCaps->machine)
if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0)
goto cleanup;
- if (VIR_STRDUP(firmwares[0]->name, "/usr/lib/xen/boot/hvmloader") < 0 ||
- VIR_STRDUP(firmwares[1]->name, "/usr/lib/xen/boot/ovmf.bin") < 0)
- goto cleanup;
+ firmwares[0]->name = g_strdup("/usr/lib/xen/boot/hvmloader");
+ firmwares[1]->name = g_strdup("/usr/lib/xen/boot/ovmf.bin");
if (libxlMakeDomainCapabilities(domCaps, firmwares, 2) < 0)
goto cleanup;
return -1;
}
} else {
- if (VIR_STRDUP_QUIET(*newpath, path) < 0)
- return -1;
+ *newpath = g_strdup(path);
}
return 0;
" </devices>\n"
"</domain>\n";
- if (!(def = virDomainDefNew()) ||
- VIR_STRDUP(def->os.init, "/sbin/init") < 0)
+ if (!(def = virDomainDefNew()))
goto cleanup;
+ def->os.init = g_strdup("/sbin/init");
+
def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
def->os.type = VIR_DOMAIN_OSTYPE_EXE;
return -1;
srcpriv->secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
- if (VIR_STRDUP(srcpriv->secinfo->s.aes.username, src->auth->username) < 0)
- return -1;
+ srcpriv->secinfo->s.aes.username = g_strdup(src->auth->username);
if (virAsprintf(&srcpriv->secinfo->s.aes.alias, "%s-secalias",
NULLSTR(src->nodestorage)) < 0)
if (flags & TEST_PARENT) {
if (def->parent.parent_name)
return -1;
- if (VIR_STRDUP(def->parent.parent_name, "1525111885") < 0)
- return -1;
+ def->parent.parent_name = g_strdup("1525111885");
}
if (flags & TEST_VDA_BITMAP) {
virDomainCheckpointDiskDefPtr disk;
return -1;
if (!disk->name) {
disk->type = VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP;
- if (VIR_STRDUP(disk->name, "vda") < 0)
- return -1;
+ disk->name = g_strdup("vda");
} else if (STRNEQ(disk->name, "vda")) {
return -1;
}
- if (VIR_STRDUP(disk->bitmap, def->parent.name) < 0)
- return -1;
+ disk->bitmap = g_strdup(def->parent.name);
}
if (flags & TEST_SIZE) {
def->disks[0].size = 1048576;
};
const size_t nexpected = G_N_ELEMENTS(expected);
- if (VIR_STRDUP(fakehome, abs_srcdir "/qemufirmwaredata/home/user/.config") < 0)
- return -1;
+ fakehome = g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config");
setenv("XDG_CONFIG_HOME", fakehome, 1);
struct testQemuHotplugCpuParams cpudata;
char *fakerootdir;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
VIR_FREE(driver.config->spiceListen);
VIR_FREE(driver.config->vncListen);
/* some dummy values from 'config file' */
- if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
- return EXIT_FAILURE;
+ driver.config->spicePassword = g_strdup("123456");
if (!(driver.domainEventState = virObjectEventStateNew()))
return EXIT_FAILURE;
char *fakerootdir;
virQEMUCapsPtr qemuCaps = NULL;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
return -1;
expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NULL, 15, 16, 17, 18, 19, 20};
- if (VIR_STRDUP(expectedInfo.group_name, "group14") < 0)
- return -1;
+ expectedInfo.group_name = g_strdup("group14");
if (qemuMonitorTestAddItem(test, "query-block", queryBlockReply) < 0 ||
qemuMonitorTestAddItemParams(test, "block_set_io_throttle",
if (VIR_ALLOC(data) < 0)
return -1;
- if (VIR_STRDUP(data->command_name, command_name) < 0 ||
- VIR_STRDUP(data->response, response) < 0) {
- qemuMonitorTestHandlerDataFree(data);
- return -1;
- }
+ data->command_name = g_strdup(command_name);
+ data->response = g_strdup(response);
return qemuMonitorTestAddHandler(test,
qemuMonitorTestProcessCommandDefault,
if (VIR_ALLOC(data) < 0)
return -1;
- if (VIR_STRDUP(data->response, response) < 0 ||
- VIR_STRDUP(data->cmderr, cmderr) < 0)
- goto error;
+ data->response = g_strdup(response);
+ data->cmderr = g_strdup(cmderr);
data->command_name = virJSONStringReformat(command, false);
if (!data->command_name)
if (VIR_ALLOC(data) < 0)
goto error;
- if (VIR_STRDUP(data->command_name, cmdname) < 0 ||
- VIR_STRDUP(data->response, response) < 0)
- goto error;
+ data->command_name = g_strdup(cmdname);
+ data->response = g_strdup(response);
while ((argname = va_arg(args, char *))) {
size_t i;
if (VIR_EXPAND_N(data->args, data->nargs, 1))
goto error;
- if (VIR_STRDUP(data->args[i].argname, argname) < 0 ||
- VIR_STRDUP(data->args[i].argval, argval) < 0)
- goto error;
+ data->args[i].argname = g_strdup(argname);
+ data->args[i].argval = g_strdup(argval);
}
va_end(args);
if (VIR_ALLOC(data) < 0)
goto error;
- if (VIR_STRDUP(data->command_name, cmdname) < 0 ||
- VIR_STRDUP(data->response, response) < 0 ||
- VIR_STRDUP(data->expectArgs, cmdargs) < 0)
- goto error;
+ data->command_name = g_strdup(cmdname);
+ data->response = g_strdup(response);
+ data->expectArgs = g_strdup(cmdargs);
if (apostrophe) {
char *tmp = data->expectArgs;
return NULL;
}
- if (VIR_STRDUP(tmpdir_template, "/tmp/libvirt_XXXXXX") < 0)
- goto error;
+ tmpdir_template = g_strdup("/tmp/libvirt_XXXXXX");
if (!(test->tmpdir = mkdtemp(tmpdir_template))) {
virReportSystemError(errno, "%s",
goto cleanup;
}
- if (VIR_STRDUP(*value, val) < 0)
- goto cleanup;
+ *value = g_strdup(val);
ret = 0;
cleanup:
char *val;
key = get_key(path, name);
- if (VIR_STRDUP(val, value) < 0)
- return -1;
+ val = g_strdup(value);
virMutexLock(&m);
init_syms();
};
const size_t nexpected = G_N_ELEMENTS(expected);
- if (VIR_STRDUP(fakehome, abs_srcdir "/qemuvhostuserdata/home/user/.config") < 0)
- return -1;
+ fakehome = g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config");
setenv("XDG_CONFIG_HOME", fakehome, 1);
unsigned int internalFlags G_GNUC_UNUSED)
{
char *secret;
- if (VIR_STRDUP(secret, "AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A") < 0)
- return NULL;
+ secret = g_strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A");
*value_size = strlen(secret);
return (unsigned char *) secret;
}
switch (vm->def->tpm->type) {
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path);
- if (VIR_STRDUP(vm->def->tpm->data.emulator.source.data.file.path,
- "/dev/test") < 0)
- goto cleanup;
+ vm->def->tpm->data.emulator.source.data.file.path = g_strdup("/dev/test");
vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
break;
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
char *fakerootdir;
virHashTablePtr capslatest = NULL;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
driver.privileged = true;
VIR_FREE(driver.config->defaultTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->defaultTLSx509certdir, "/etc/pki/qemu") < 0)
- return EXIT_FAILURE;
+ driver.config->defaultTLSx509certdir = g_strdup("/etc/pki/qemu");
VIR_FREE(driver.config->vncTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvirt-vnc") < 0)
- return EXIT_FAILURE;
+ driver.config->vncTLSx509certdir = g_strdup("/etc/pki/libvirt-vnc");
VIR_FREE(driver.config->spiceTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/libvirt-spice") < 0)
- return EXIT_FAILURE;
+ driver.config->spiceTLSx509certdir = g_strdup("/etc/pki/libvirt-spice");
VIR_FREE(driver.config->chardevTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
- return EXIT_FAILURE;
+ driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
VIR_FREE(driver.config->vxhsTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->vxhsTLSx509certdir, "/etc/pki/libvirt-vxhs/dummy,path") < 0)
- return EXIT_FAILURE;
+ driver.config->vxhsTLSx509certdir = g_strdup("/etc/pki/libvirt-vxhs/dummy,path");
VIR_FREE(driver.config->nbdTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->nbdTLSx509certdir, "/etc/pki/libvirt-nbd/dummy,path") < 0)
- return EXIT_FAILURE;
+ driver.config->nbdTLSx509certdir = g_strdup("/etc/pki/libvirt-nbd/dummy,path");
VIR_FREE(driver.config->hugetlbfs);
if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0)
return EXIT_FAILURE;
driver.config->nhugetlbfs = 2;
- if (VIR_STRDUP(driver.config->hugetlbfs[0].mnt_dir, "/dev/hugepages2M") < 0 ||
- VIR_STRDUP(driver.config->hugetlbfs[1].mnt_dir, "/dev/hugepages1G") < 0)
- return EXIT_FAILURE;
+ driver.config->hugetlbfs[0].mnt_dir = g_strdup("/dev/hugepages2M");
+ driver.config->hugetlbfs[1].mnt_dir = g_strdup("/dev/hugepages1G");
driver.config->hugetlbfs[0].size = 2048;
driver.config->hugetlbfs[0].deflt = true;
driver.config->hugetlbfs[1].size = 1048576;
driver.config->spiceTLS = 1;
- if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
- return EXIT_FAILURE;
+ driver.config->spicePassword = g_strdup("123456");
VIR_FREE(driver.config->memoryBackingDir);
- if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0)
- return EXIT_FAILURE;
+ driver.config->memoryBackingDir = g_strdup("/var/lib/libvirt/qemu/ram");
VIR_FREE(driver.config->nvramDir);
- if (VIR_STRDUP(driver.config->nvramDir, "/var/lib/libvirt/qemu/nvram") < 0)
- return EXIT_FAILURE;
+ driver.config->nvramDir = g_strdup("/var/lib/libvirt/qemu/nvram");
capslatest = testQemuGetLatestCaps();
if (!capslatest)
DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA);
DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0");
DO_TEST_CAPS_LATEST("graphics-vnc-tls");
- if (VIR_STRDUP_QUIET(driver.config->vncTLSx509secretUUID,
- "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0)
- return EXIT_FAILURE;
+ driver.config->vncTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
DO_TEST_CAPS_LATEST("graphics-vnc-tls-secret");
VIR_FREE(driver.config->vncTLSx509secretUUID);
driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
QEMU_CAPS_DEVICE_ISA_SERIAL,
QEMU_CAPS_OBJECT_TLS_CREDS_X509);
VIR_FREE(driver.config->chardevTLSx509certdir);
- if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/libvirt-chardev") < 0)
- return EXIT_FAILURE;
- if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509secretUUID,
- "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0)
- return EXIT_FAILURE;
+ driver.config->chardevTLSx509certdir = g_strdup("/etc/pki/libvirt-chardev");
+ driver.config->chardevTLSx509secretUUID = g_strdup("6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea");
DO_TEST("serial-tcp-tlsx509-secret-chardev",
QEMU_CAPS_OBJECT_SECRET,
QEMU_CAPS_DEVICE_ISA_SERIAL,
if (!capslatest)
return EXIT_FAILURE;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
char *fakerootdir = NULL;
char *fakesysfsdir = NULL;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- goto cleanup;
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
abs_builddir, line) < 0)
goto cleanup;
if (*tmp != '\0' && *tmp != '\n') {
- if (VIR_STRDUP(context, tmp) < 0) {
- VIR_FREE(file);
- goto cleanup;
- }
+ context = g_strdup(tmp);
tmp = strchr(context, '\n');
if (tmp)
if (errno == ENODATA) {
/* nothing to do */
} else if (errno == EOPNOTSUPP) {
- if (VIR_STRDUP(ctx, "EOPNOTSUPP") < 0)
- return -1;
+ ctx = g_strdup("EOPNOTSUPP");
} else {
virReportSystemError(errno,
"Cannot read label on %s",
if (VIR_ALLOC(secdef) < 0)
goto error;
- if (VIR_STRDUP(secdef->model, "selinux") < 0)
- goto error;
+ secdef->model = g_strdup("selinux");
secdef->type = dynamic ? VIR_DOMAIN_SECLABEL_DYNAMIC : VIR_DOMAIN_SECLABEL_STATIC;
- if (label &&
- VIR_STRDUP(secdef->label, label) < 0)
- goto error;
+ if (label)
+ secdef->label = g_strdup(label);
- if (baselabel &&
- VIR_STRDUP(secdef->baselabel, baselabel) < 0)
- goto error;
+ if (baselabel)
+ secdef->baselabel = g_strdup(baselabel);
def->seclabels[0] = secdef;
def->nseclabels++;
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
return -1;
- if (VIR_STRDUP(output, test.output) < 0)
- return -1;
+ output = g_strdup(test.output);
if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=
test.expected_return)
if (!(vol = virStorageVolDefParseFile(pool, data->volxml, 0)))
return -1;
- if (VIR_STRDUP(output, test.output) < 0)
- return -1;
+ output = g_strdup(test.output);
if (virStorageBackendSheepdogParseVdiList(vol, output) !=
test.expected_return)
virAsprintf(&new_path, "%s:%s", abs_builddir, path) < 0)
goto cleanup;
} else {
- if (VIR_STRDUP(new_path, abs_builddir) < 0)
- goto cleanup;
+ new_path = g_strdup(abs_builddir);
}
if (new_path &&
"pc-0.11", "pc", "pc-0.10", "isapc"
};
- if (VIR_STRDUP(canonical, x86_machines[0]) < 0)
- return NULL;
+ canonical = g_strdup(x86_machines[0]);
machines = virCapabilitiesAllocMachines(x86_machines,
G_N_ELEMENTS(x86_machines));
goto cleanup;
caps->host.nsecModels = 1;
- if (VIR_STRDUP(caps->host.secModels[0].model, "none") < 0 ||
- VIR_STRDUP(caps->host.secModels[0].doi, "0") < 0)
- goto cleanup;
+ caps->host.secModels[0].model = g_strdup("none");
+ caps->host.secModels[0].doi = g_strdup("0");
if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) ||
!(cpuHaswell = virCPUDefCopy(&cpuHaswellData)) ||
/* Overwrite some default paths so it's consistent for tests. */
VIR_FREE(driver->config->libDir);
VIR_FREE(driver->config->channelTargetDir);
- if (VIR_STRDUP(driver->config->libDir, "/tmp/lib") < 0 ||
- VIR_STRDUP(driver->config->channelTargetDir, "/tmp/channel") < 0)
- goto error;
+ driver->config->libDir = g_strdup("/tmp/lib");
+ driver->config->channelTargetDir = g_strdup("/tmp/channel");
if (!mkdtemp(statedir)) {
virFilePrintf(stderr, "Cannot create fake stateDir");
goto error;
}
- if (VIR_STRDUP(driver->config->stateDir, statedir) < 0) {
- rmdir(statedir);
- goto error;
- }
+ driver->config->stateDir = g_strdup(statedir);
if (!mkdtemp(configdir)) {
virFilePrintf(stderr, "Cannot create fake configDir");
goto error;
}
- if (VIR_STRDUP(driver->config->configDir, configdir) < 0) {
- rmdir(configdir);
- goto error;
- }
+ driver->config->configDir = g_strdup(configdir);
driver->caps = testQemuCapsInit();
if (!driver->caps)
while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
VIR_FREE(tmp);
- if ((rc = VIR_STRDUP(tmp, STRSKIP(ent->d_name, "caps_"))) < 0)
- goto cleanup;
+ tmp = g_strdup(STRSKIP(ent->d_name, "caps_"));
- if (rc == 0)
+ if (!tmp)
continue;
if (!virStringStripSuffix(tmp, fullsuffix))
bool stripmachinealiases = false;
if (STREQ(capsver, "latest")) {
- if (VIR_STRDUP(capsfile, virHashLookup(capslatest, capsarch)) < 0)
- goto cleanup;
+ capsfile = g_strdup(virHashLookup(capslatest, capsarch));
stripmachinealiases = true;
} else if (virAsprintf(&capsfile, "%s/caps_%s.%s.xml",
TEST_QEMU_CAPS_PATH, capsver, capsarch) < 0) {
int ret = -1;
virVBoxSnapshotConfMachinePtr machine = NULL;
- if (VIR_STRDUP(pathResult,
- abs_builddir "/vboxsnapshotxmldata/testResult.vbox") < 0)
- return -1;
+ pathResult = g_strdup(abs_builddir "/vboxsnapshotxmldata/testResult.vbox");
if (virFileMakePath(abs_builddir "/vboxsnapshotxmldata") < 0)
goto cleanup;
VIR_DISPOSE_N(nums, nnums);
- if (VIR_STRDUP(str, "test") < 0)
- return -1;
+ str = g_strdup("test");
VIR_DISPOSE_STRING(str);
{
char *fakerootdir;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
if (!(obj = virObjectNew(testFileCacheObjClass)))
return NULL;
- if (VIR_STRDUP(obj->data, data) < 0)
- goto error;
+ obj->data = g_strdup(data);
return obj;
-
- error:
- virObjectUnref(obj);
- return NULL;
}
const char *input G_GNUC_UNUSED,
char **output,
char **error G_GNUC_UNUSED,
- int *status,
+ int *status G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{
if (STREQ(args[0], IPTABLES_PATH) &&
STREQ(args[1], "-L")) {
- if (VIR_STRDUP(*output, TEST_FILTER_TABLE_LIST) < 0)
- *status = 127;
+ *output = g_strdup(TEST_FILTER_TABLE_LIST);
} else if (STREQ(args[0], IPTABLES_PATH) &&
STREQ(args[1], "-t") &&
STREQ(args[2], "nat") &&
STREQ(args[3], "-L")) {
- if (VIR_STRDUP(*output, TEST_NAT_TABLE_LIST) < 0)
- *status = 127;
+ *output = g_strdup(TEST_NAT_TABLE_LIST);
}
}
goto cleanup;
if ((mgr->activeSCSIHostdevs = virSCSIDeviceListNew()) == NULL)
goto cleanup;
- if (VIR_STRDUP(mgr->stateDir, TEST_STATE_DIR) < 0)
- goto cleanup;
+ mgr->stateDir = g_strdup(TEST_STATE_DIR);
if (virFileMakePath(mgr->stateDir) < 0)
goto cleanup;
int ret = 0;
g_autofree char *fakerootdir = NULL;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- fprintf(stderr, "Out of memory\n");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
fprintf(stderr, "Cannot create fakerootdir");
err.level = VIR_ERR_ERROR;
if (VIR_ALLOC(err.message) < 0 ||
- VIR_STRDUP(*err.message, "Hello World") < 0 ||
VIR_ALLOC(err.str1) < 0 ||
- VIR_STRDUP(*err.str1, "One") < 0 ||
VIR_ALLOC(err.str2) < 0 ||
- VIR_STRDUP(*err.str2, "Two") < 0 ||
- VIR_ALLOC(err.str3) < 0 ||
- VIR_STRDUP(*err.str3, "Three") < 0)
+ VIR_ALLOC(err.str3) < 0)
goto cleanup;
+ *err.message = g_strdup("Hello World");
+ *err.str1 = g_strdup("One");
+ *err.str2 = g_strdup("Two");
+ *err.str3 = g_strdup("Three");
+
err.int1 = 1;
err.int2 = 2;
return -1;
}
} else {
- if (VIR_STRDUP_QUIET(*newpath, path) < 0)
- return -1;
+ *newpath = g_strdup(path);
}
return 0;
fd, path, cb.fd, cb.path);
}
- if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0 ||
- VIR_STRDUP_QUIET(callbacks[nCallbacks].path, path) < 0) {
+ if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0) {
errno = ENOMEM;
goto cleanup;
}
+ callbacks[nCallbacks].path = g_strdup(path);
callbacks[nCallbacks++].fd = fd;
ret = 0;
cleanup:
struct stat sb;
bool configSrcExists = false;
- if (!(devid = pci_address_format(&data->addr)) ||
- VIR_STRDUP_QUIET(id, devid) < 0)
+ if (!(devid = pci_address_format(&data->addr)))
ABORT_OOM();
+ id = g_strdup(devid);
+
/* Replace ':' with '-' to create the config filename from the
* device ID. The device ID cannot be used directly as filename
* because it contains ':' and Windows does not allow ':' in
int vendor, device;
g_autofree char *driverpath = NULL;
- if (VIR_ALLOC_QUIET(driver) < 0 ||
- VIR_STRDUP_QUIET(driver->name, name) < 0 ||
- !(driverpath = pci_driver_get_path(driver, NULL, true)))
+ if (VIR_ALLOC_QUIET(driver) < 0)
+ ABORT_OOM();
+ driver->name = g_strdup(name);
+ if (!(driverpath = pci_driver_get_path(driver, NULL, true)))
ABORT_OOM();
if (virFileMakePath(driverpath) < 0)
int ret = 0;
char *fakerootdir;
- if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
- VIR_TEST_DEBUG("Out of memory");
- abort();
- }
+ fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
if (!mkdtemp(fakerootdir)) {
VIR_TEST_DEBUG("Cannot create fakerootdir");
VIR_FREE(virscsi_prefix);
- if (VIR_STRDUP(virscsi_prefix, tmpdir) < 0) {
- ret = -1;
- goto cleanup;
- }
+ virscsi_prefix = g_strdup(tmpdir);
if (virTestRun("test1", test1, NULL) < 0)
ret = -1;
}
}
- if (VIR_STRDUP(def->path, path) < 0)
- return NULL;
+ def->path = g_strdup(path);
if (virStorageFileGetMetadata(def, uid, gid, false) < 0)
return NULL;
for (i = 0; i < G_N_ELEMENTS(testPathCanonicalizeSymlinks); i++) {
if (STREQ(path, testPathCanonicalizeSymlinks[i][0])) {
- if (VIR_STRDUP(*linkpath, testPathCanonicalizeSymlinks[i][1]) < 0)
- return -1;
+ *linkpath = g_strdup(testPathCanonicalizeSymlinks[i][1]);
return 0;
}
int ret = -1;
char *res = NULL;
- if (VIR_STRDUP(res, data->string) < 0)
- goto cleanup;
+ res = g_strdup(data->string);
virStringStripIPv6Brackets(res);
int ret = -1;
char *res = NULL;
- if (VIR_STRDUP(res, data->string) < 0)
- goto cleanup;
+ res = g_strdup(data->string);
virStringStripControlChars(res);
int ret = -1;
char *res = NULL;
- if (VIR_STRDUP(res, data->string) < 0)
- goto cleanup;
+ res = g_strdup(data->string);
virStringFilterChars(res, data->valid);
} else {
/* Yeah, our worst nightmares just became true. Path does
* not exist. Cut off the last component and retry. */
- if (VIR_STRDUP_QUIET(crippledPath, relPath ? relPath : path) < 0)
- goto error;
+ crippledPath = g_strdup(relPath ? relPath : path);
virFileRemoveLastComponent(crippledPath);
if ((p = STRSKIP(real_path, USB_SYSFS)) &&
virAsprintfQuiet(&path, "%s/%s/%s", abs_srcdir, FAKE_USB_SYSFS, p) < 0)
goto error;
- else if (!p && VIR_STRDUP_QUIET(path, real_path) < 0)
- goto error;
+ else if (!p)
+ path = g_strdup(real_path);
return path;
if (STRPREFIX(fileName, "/vmfs/volumes/")) {
/* Found absolute path referencing a file inside a datastore */
- if (VIR_STRDUP(copyOfFileName, fileName) < 0)
- goto cleanup;
+ copyOfFileName = g_strdup(fileName);
/* Expected format: '/vmfs/volumes/<datastore>/<path>' */
if ((tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) == NULL ||
if (STRPREFIX(src, "[")) {
/* Found potential datastore path */
- if (VIR_STRDUP(copyOfDatastorePath, src) < 0)
- goto cleanup;
+ copyOfDatastorePath = g_strdup(src);
/* Expected format: '[<datastore>] <path>' where <path> is optional */
if ((tmp = STRSKIP(copyOfDatastorePath, "[")) == NULL || *tmp == ']' ||