Replace all occurrences of
if (VIR_STRDUP(a, b) < 0)
/* effectively dead code */
with:
a = g_strdup(b);
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/libxl/libxl_capabilities.c | 4 +-
src/libxl/libxl_conf.c | 185 +++++++++++----------------------
src/libxl/libxl_driver.c | 18 ++--
src/libxl/libxl_migration.c | 8 +-
src/libxl/xen_common.c | 62 ++++-------
src/libxl/xen_xl.c | 30 ++----
src/libxl/xen_xm.c | 3 +-
7 files changed, 101 insertions(+), 209 deletions(-)
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 54a8c090b0..3b88121dca 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -615,9 +615,7 @@ libxlMakeDomainOSCaps(const char *machine,
return -1;
for (i = 0; i < nfirmwares; i++) {
- if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalues],
- firmwares[i]->name) < 0)
- return -1;
+ capsLoader->values.values[capsLoader->values.nvalues] =
g_strdup(firmwares[i]->name);
capsLoader->values.nvalues++;
}
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index bbf0f8d8c1..3f08f0f710 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -162,8 +162,7 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx,
c_info->type = LIBXL_DOMAIN_TYPE_PV;
}
- if (VIR_STRDUP(c_info->name, def->name) < 0)
- goto error;
+ c_info->name = g_strdup(def->name);
if (def->nseclabels &&
def->seclabels[0]->type == VIR_DOMAIN_SECLABEL_STATIC) {
@@ -208,8 +207,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
case VIR_DOMAIN_CHR_TYPE_STDIO:
case VIR_DOMAIN_CHR_TYPE_VC:
case VIR_DOMAIN_CHR_TYPE_PTY:
- if (VIR_STRDUP(*buf, type) < 0)
- return -1;
+ *buf = g_strdup(type);
break;
case VIR_DOMAIN_CHR_TYPE_FILE:
@@ -219,8 +217,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
break;
case VIR_DOMAIN_CHR_TYPE_DEV:
- if (VIR_STRDUP(*buf, srcdef->data.file.path) < 0)
- return -1;
+ *buf = g_strdup(srcdef->data.file.path);
break;
case VIR_DOMAIN_CHR_TYPE_UDP: {
@@ -507,9 +504,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
VIR_TRISTATE_SWITCH_ON);
/* copy SLIC table path to acpi_firmware */
- if (def->os.slic_table &&
- VIR_STRDUP(b_info->u.hvm.acpi_firmware, def->os.slic_table) <
0)
- return -1;
+ if (def->os.slic_table)
+ b_info->u.hvm.acpi_firmware = g_strdup(def->os.slic_table);
if (def->nsounds > 0) {
/*
@@ -518,9 +514,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
*/
virDomainSoundDefPtr snd = def->sounds[0];
- if (VIR_STRDUP(b_info->u.hvm.soundhw,
- virDomainSoundModelTypeToString(snd->model)) < 0)
- return -1;
+ b_info->u.hvm.soundhw =
g_strdup(virDomainSoundModelTypeToString(snd->model));
}
for (i = 0; i < def->os.nBootDevs; i++) {
@@ -546,16 +540,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
} else {
bootorder[def->os.nBootDevs] = '\0';
}
- if (VIR_STRDUP(b_info->u.hvm.boot, bootorder) < 0)
- return -1;
+ b_info->u.hvm.boot = g_strdup(bootorder);
#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
- if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0)
- return -1;
- if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0)
- return -1;
- if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0)
- return -1;
+ b_info->cmdline = g_strdup(def->os.cmdline);
+ b_info->kernel = g_strdup(def->os.kernel);
+ b_info->ramdisk = g_strdup(def->os.initrd);
#endif
/*
@@ -587,8 +577,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
}
VIR_FREE(b_info->device_model);
- if (VIR_STRDUP(b_info->device_model, def->emulator) < 0)
- return -1;
+ b_info->device_model = g_strdup(def->emulator);
b_info->device_model_version = libxlDomainGetEmulatorType(def);
}
@@ -658,13 +647,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
switch (def->inputs[i]->type) {
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
VIR_FREE(*usbdevice);
- if (VIR_STRDUP(*usbdevice, "mouse") < 0)
- return -1;
+ *usbdevice = g_strdup("mouse");
break;
case VIR_DOMAIN_INPUT_TYPE_TABLET:
VIR_FREE(*usbdevice);
- if (VIR_STRDUP(*usbdevice, "tablet") < 0)
- return -1;
+ *usbdevice = g_strdup("tablet");
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -682,15 +669,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
}
#endif
} else if (pvh) {
- if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0)
- return -1;
- if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0)
- return -1;
- if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0)
- return -1;
+ b_info->cmdline = g_strdup(def->os.cmdline);
+ b_info->kernel = g_strdup(def->os.kernel);
+ b_info->ramdisk = g_strdup(def->os.initrd);
#ifdef LIBXL_HAVE_BUILDINFO_BOOTLOADER
- if (VIR_STRDUP(b_info->bootloader, def->os.bootloader) < 0)
- return -1;
+ b_info->bootloader = g_strdup(def->os.bootloader);
if (def->os.bootloaderArgs) {
if (!(b_info->bootloader_args =
virStringSplit(def->os.bootloaderArgs, " \t\n", 0)))
@@ -703,27 +686,22 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
* if bootloader is not specified AND direct kernel boot is not specified.
*/
if (def->os.bootloader) {
- if (VIR_STRDUP(b_info->u.pv.bootloader, def->os.bootloader) < 0)
- return -1;
+ b_info->u.pv.bootloader = g_strdup(def->os.bootloader);
} else if (def->os.kernel == NULL) {
- if (VIR_STRDUP(b_info->u.pv.bootloader, LIBXL_BOOTLOADER_PATH) < 0)
- return -1;
+ b_info->u.pv.bootloader = g_strdup(LIBXL_BOOTLOADER_PATH);
}
if (def->os.bootloaderArgs) {
if (!(b_info->u.pv.bootloader_args =
virStringSplit(def->os.bootloaderArgs, " \t\n", 0)))
return -1;
}
- if (VIR_STRDUP(b_info->u.pv.cmdline, def->os.cmdline) < 0)
- return -1;
+ b_info->u.pv.cmdline = g_strdup(def->os.cmdline);
if (def->os.kernel) {
- /* libxl_init_build_info() sets VIR_STRDUP(kernel.path,
"hvmloader") */
+ /* libxl_init_build_info() sets kernel.path = g_strdup("hvmloader")
*/
VIR_FREE(b_info->u.pv.kernel);
- if (VIR_STRDUP(b_info->u.pv.kernel, def->os.kernel) < 0)
- return -1;
+ b_info->u.pv.kernel = g_strdup(def->os.kernel);
}
- if (VIR_STRDUP(b_info->u.pv.ramdisk, def->os.initrd) < 0)
- return -1;
+ b_info->u.pv.ramdisk = g_strdup(def->os.initrd);
}
/* only the 'xen' balloon device model is supported */
@@ -1036,12 +1014,10 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk
*x_disk)
if (libxlMakeNetworkDiskSrc(l_disk->src, &x_disk->pdev_path) < 0)
return -1;
} else {
- if (VIR_STRDUP(x_disk->pdev_path, virDomainDiskGetSource(l_disk)) < 0)
- return -1;
+ x_disk->pdev_path = g_strdup(virDomainDiskGetSource(l_disk));
}
- if (VIR_STRDUP(x_disk->vdev, l_disk->dst) < 0)
- return -1;
+ x_disk->vdev = g_strdup(l_disk->dst);
if (driver) {
if (STREQ(driver, "tap") || STREQ(driver, "tap2")) {
@@ -1159,8 +1135,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk
*x_disk)
if (l_disk->domain_name) {
#ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME
- if (VIR_STRDUP(x_disk->backend_domname, l_disk->domain_name) < 0)
- return -1;
+ x_disk->backend_domname = g_strdup(l_disk->domain_name);
#else
virReportError(VIR_ERR_XML_DETAIL, "%s",
_("this version of libxenlight does not "
@@ -1289,8 +1264,7 @@ libxlMakeNic(virDomainDefPtr def,
"Xen PV(H) domains"));
return -1;
}
- if (VIR_STRDUP(x_nic->model, virDomainNetGetModelString(l_nic)) < 0)
- goto cleanup;
+ x_nic->model = g_strdup(virDomainNetGetModelString(l_nic));
if (l_nic->model == VIR_DOMAIN_NET_MODEL_NETFRONT)
x_nic->nictype = LIBXL_NIC_TYPE_VIF;
else
@@ -1302,8 +1276,7 @@ libxlMakeNic(virDomainDefPtr def,
x_nic->nictype = LIBXL_NIC_TYPE_VIF;
}
- if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0)
- goto cleanup;
+ x_nic->ifname = g_strdup(l_nic->ifname);
port_profile = virDomainNetGetActualVirtPortProfile(l_nic);
virt_vlan = virDomainNetGetActualVlan(l_nic);
@@ -1343,13 +1316,10 @@ libxlMakeNic(virDomainDefPtr def,
}
if (virBufferCheckError(&buf) < 0)
goto cleanup;
- if (VIR_STRDUP(x_nic->bridge,
- virBufferCurrentContent(&buf)) < 0)
- goto cleanup;
+ x_nic->bridge = g_strdup(virBufferCurrentContent(&buf));
G_GNUC_FALLTHROUGH;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
- if (VIR_STRDUP(x_nic->script, script) < 0)
- goto cleanup;
+ x_nic->script = g_strdup(script);
if (l_nic->guestIP.nips > 0) {
x_nic->ip = xenMakeIPList(&l_nic->guestIP);
if (!x_nic->ip)
@@ -1394,8 +1364,7 @@ libxlMakeNic(virDomainDefPtr def,
if (l_nic->domain_name) {
#ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME
- if (VIR_STRDUP(x_nic->backend_domname, l_nic->domain_name) < 0)
- goto cleanup;
+ x_nic->backend_domname = g_strdup(l_nic->domain_name);
#else
virReportError(VIR_ERR_XML_DETAIL, "%s",
_("this version of libxenlight does not "
@@ -1508,10 +1477,8 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports,
libxl_defbool_set(&x_vfb->sdl.enable, 1);
libxl_defbool_set(&x_vfb->vnc.enable, 0);
libxl_defbool_set(&x_vfb->sdl.opengl, 0);
- if (VIR_STRDUP(x_vfb->sdl.display, l_vfb->data.sdl.display) < 0)
- return -1;
- if (VIR_STRDUP(x_vfb->sdl.xauthority, l_vfb->data.sdl.xauth) < 0)
- return -1;
+ x_vfb->sdl.display = g_strdup(l_vfb->data.sdl.display);
+ x_vfb->sdl.xauthority = g_strdup(l_vfb->data.sdl.xauth);
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
libxl_defbool_set(&x_vfb->vnc.enable, 1);
@@ -1528,20 +1495,16 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports,
if ((glisten = virDomainGraphicsGetListen(l_vfb, 0))) {
if (glisten->address) {
- /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1") */
+ /* libxl_device_vfb_init() does g_strdup("127.0.0.1") */
VIR_FREE(x_vfb->vnc.listen);
- if (VIR_STRDUP(x_vfb->vnc.listen, glisten->address) < 0)
- return -1;
+ x_vfb->vnc.listen = g_strdup(glisten->address);
} else {
- if (VIR_STRDUP(glisten->address, VIR_LOOPBACK_IPV4_ADDR) < 0)
- return -1;
+ glisten->address = g_strdup(VIR_LOOPBACK_IPV4_ADDR);
}
}
- if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd) < 0)
- return -1;
- if (VIR_STRDUP(x_vfb->keymap, l_vfb->data.vnc.keymap) < 0)
- return -1;
+ x_vfb->vnc.passwd = g_strdup(l_vfb->data.vnc.auth.passwd);
+ x_vfb->keymap = g_strdup(l_vfb->data.vnc.keymap);
break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
@@ -1642,22 +1605,17 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr graphicsports,
if ((glisten = virDomainGraphicsGetListen(l_vfb, 0))) {
if (glisten->address) {
- if (VIR_STRDUP(b_info->u.hvm.spice.host, glisten->address) < 0)
- return -1;
+ b_info->u.hvm.spice.host = g_strdup(glisten->address);
} else {
- if (VIR_STRDUP(b_info->u.hvm.spice.host, VIR_LOOPBACK_IPV4_ADDR) <
0 ||
- VIR_STRDUP(glisten->address, VIR_LOOPBACK_IPV4_ADDR) < 0)
- return -1;
+ b_info->u.hvm.spice.host = g_strdup(VIR_LOOPBACK_IPV4_ADDR);
+ glisten->address = g_strdup(VIR_LOOPBACK_IPV4_ADDR);
}
}
- if (VIR_STRDUP(b_info->u.hvm.keymap, l_vfb->data.spice.keymap) < 0)
- return -1;
+ b_info->u.hvm.keymap = g_strdup(l_vfb->data.spice.keymap);
if (l_vfb->data.spice.auth.passwd) {
- if (VIR_STRDUP(b_info->u.hvm.spice.passwd,
- l_vfb->data.spice.auth.passwd) < 0)
- return -1;
+ b_info->u.hvm.spice.passwd = g_strdup(l_vfb->data.spice.auth.passwd);
libxl_defbool_set(&b_info->u.hvm.spice.disable_ticketing, false);
} else {
libxl_defbool_set(&b_info->u.hvm.spice.disable_ticketing, true);
@@ -1693,10 +1651,8 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr graphicsports,
if (libxl_defbool_val(x_vfb.vnc.enable)) {
libxl_defbool_set(&b_info->u.hvm.vnc.enable, true);
- if (VIR_STRDUP(b_info->u.hvm.vnc.listen, x_vfb.vnc.listen) < 0)
- return -1;
- if (VIR_STRDUP(b_info->u.hvm.vnc.passwd, x_vfb.vnc.passwd) < 0)
- return -1;
+ b_info->u.hvm.vnc.listen = g_strdup(x_vfb.vnc.listen);
+ b_info->u.hvm.vnc.passwd = g_strdup(x_vfb.vnc.passwd);
b_info->u.hvm.vnc.display = x_vfb.vnc.display;
libxl_defbool_set(&b_info->u.hvm.vnc.findunused,
libxl_defbool_val(x_vfb.vnc.findunused));
@@ -1704,14 +1660,11 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr graphicsports,
libxl_defbool_set(&b_info->u.hvm.sdl.enable, true);
libxl_defbool_set(&b_info->u.hvm.sdl.opengl,
libxl_defbool_val(x_vfb.sdl.opengl));
- if (VIR_STRDUP(b_info->u.hvm.sdl.display, x_vfb.sdl.display) < 0)
- return -1;
- if (VIR_STRDUP(b_info->u.hvm.sdl.xauthority, x_vfb.sdl.xauthority) < 0)
- return -1;
+ b_info->u.hvm.sdl.display = g_strdup(x_vfb.sdl.display);
+ b_info->u.hvm.sdl.xauthority = g_strdup(x_vfb.sdl.xauthority);
}
- if (VIR_STRDUP(b_info->u.hvm.keymap, x_vfb.keymap) < 0)
- return -1;
+ b_info->u.hvm.keymap = g_strdup(x_vfb.keymap);
return 0;
}
@@ -1766,24 +1719,15 @@ libxlDriverConfigNew(void)
if (!(cfg = virObjectNew(libxlDriverConfigClass)))
return NULL;
- if (VIR_STRDUP(cfg->configBaseDir, LIBXL_CONFIG_BASE_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->configDir, LIBXL_CONFIG_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->autostartDir, LIBXL_AUTOSTART_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->logDir, LIBXL_LOG_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->stateDir, LIBXL_STATE_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->libDir, LIBXL_LIB_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->saveDir, LIBXL_SAVE_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->autoDumpDir, LIBXL_DUMP_DIR) < 0)
- goto error;
- if (VIR_STRDUP(cfg->channelDir, LIBXL_CHANNEL_DIR) < 0)
- goto error;
+ cfg->configBaseDir = g_strdup(LIBXL_CONFIG_BASE_DIR);
+ cfg->configDir = g_strdup(LIBXL_CONFIG_DIR);
+ cfg->autostartDir = g_strdup(LIBXL_AUTOSTART_DIR);
+ cfg->logDir = g_strdup(LIBXL_LOG_DIR);
+ cfg->stateDir = g_strdup(LIBXL_STATE_DIR);
+ cfg->libDir = g_strdup(LIBXL_LIB_DIR);
+ cfg->saveDir = g_strdup(LIBXL_SAVE_DIR);
+ cfg->autoDumpDir = g_strdup(LIBXL_DUMP_DIR);
+ cfg->channelDir = g_strdup(LIBXL_CHANNEL_DIR);
if (virFileMakePath(cfg->logDir) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1832,9 +1776,7 @@ libxlDriverConfigNew(void)
cfg->nfirmwares = 1;
if (VIR_ALLOC(cfg->firmwares[0]) < 0)
goto error;
- if (VIR_STRDUP(cfg->firmwares[0]->name,
- LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0)
- goto error;
+ cfg->firmwares[0]->name = g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin");
#endif
/* Always add hvmloader to firmwares */
@@ -1843,9 +1785,7 @@ libxlDriverConfigNew(void)
cfg->nfirmwares++;
if (VIR_ALLOC(cfg->firmwares[cfg->nfirmwares - 1]) < 0)
goto error;
- if (VIR_STRDUP(cfg->firmwares[cfg->nfirmwares - 1]->name,
- LIBXL_FIRMWARE_DIR "/hvmloader") < 0)
- goto error;
+ cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR
"/hvmloader");
return cfg;
@@ -2027,9 +1967,7 @@ libxlMakeChannel(virDomainChrDefPtr l_channel,
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
x_channel->connection = LIBXL_CHANNEL_CONNECTION_SOCKET;
- if (VIR_STRDUP(x_channel->u.socket.path,
- l_channel->source->data.nix.path) < 0)
- return -1;
+ x_channel->u.socket.path = g_strdup(l_channel->source->data.nix.path);
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2043,8 +1981,7 @@ libxlMakeChannel(virDomainChrDefPtr l_channel,
return -1;
}
- if (VIR_STRDUP(x_channel->name, l_channel->target.name) < 0)
- return -1;
+ x_channel->name = g_strdup(l_channel->target.name);
return 0;
}
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index eaa35481ed..ceedeb3795 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -610,8 +610,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
def->id = 0;
def->virtType = VIR_DOMAIN_VIRT_XEN;
- if (VIR_STRDUP(def->name, "Domain-0") < 0)
- goto cleanup;
+ def->name = g_strdup("Domain-0");
def->os.type = VIR_DOMAIN_OSTYPE_XEN;
@@ -1577,8 +1576,7 @@ libxlDomainGetOSType(virDomainPtr dom)
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
- goto cleanup;
+ type = g_strdup(virDomainOSTypeToString(vm->def->os.type));
cleanup:
virDomainObjEndAPI(&vm);
@@ -5438,8 +5436,7 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm,
size = libxlDiskSectorSize(vm->def->id, devno);
- if (VIR_STRDUP(stats->backend, "vbd") < 0)
- return ret;
+ stats->backend = g_strdup("vbd");
if (virAsprintf(&path,
"/sys/bus/xen-backend/devices/vbd-%d-%d/statistics",
vm->def->id, devno) < 0)
@@ -6306,19 +6303,16 @@ libxlGetDHCPInterfaces(virDomainPtr dom,
if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0)
goto error;
- if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
- goto cleanup;
+ iface->name = g_strdup(vm->def->nets[i]->ifname);
- if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
- goto cleanup;
+ iface->hwaddr = g_strdup(macaddr);
}
for (j = 0; j < n_leases; j++) {
virNetworkDHCPLeasePtr lease = leases[j];
virDomainIPAddressPtr ip_addr = &iface->addrs[j];
- if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0)
- goto cleanup;
+ ip_addr->addr = g_strdup(lease->ipaddr);
ip_addr->type = lease->type;
ip_addr->prefix = lease->prefix;
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 770a300316..0a57b6fcb0 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -94,8 +94,7 @@ libxlMigrationCookieNew(virDomainObjPtr dom)
if (VIR_ALLOC(mig) < 0)
goto error;
- if (VIR_STRDUP(mig->name, dom->def->name) < 0)
- goto error;
+ mig->name = g_strdup(dom->def->name);
memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN);
@@ -462,10 +461,7 @@ libxlDomainMigrationDstPrepareDef(libxlDriverPrivatePtr driver,
if (dname) {
name = def->name;
- if (VIR_STRDUP(def->name, dname) < 0) {
- virDomainDefFree(def);
- def = NULL;
- }
+ def->name = g_strdup(dname);
}
cleanup:
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 1a36a632aa..cc9039a0cf 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -236,8 +236,7 @@ xenConfigGetString(virConfPtr conf,
return -1;
if (rc == 0 || !string) {
- if (VIR_STRDUP(*value, def) < 0)
- return -1;
+ *value = g_strdup(def);
} else {
*value = string;
}
@@ -277,10 +276,7 @@ xenConfigSetString(virConfPtr conf, const char *setting, const char
*str)
value->type = VIR_CONF_STRING;
value->next = NULL;
- if (VIR_STRDUP(value->str, str) < 0) {
- VIR_FREE(value);
- return -1;
- }
+ value->str = g_strdup(str);
return virConfSetValue(conf, setting, value);
}
@@ -702,14 +698,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
if (STREQ(key + 10, "1"))
graphics->data.vnc.autoport = true;
} else if (STRPREFIX(key, "vnclisten=")) {
- if (VIR_STRDUP(listenAddr, key+10) < 0)
- goto cleanup;
+ listenAddr = g_strdup(key + 10);
} else if (STRPREFIX(key, "vncpasswd=")) {
- if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) <
0)
- goto cleanup;
+ graphics->data.vnc.auth.passwd = g_strdup(key + 10);
} else if (STRPREFIX(key, "keymap=")) {
- if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0)
- goto cleanup;
+ graphics->data.vnc.keymap = g_strdup(key + 7);
} else if (STRPREFIX(key, "vncdisplay=")) {
if (virStrToLong_i(key + 11, NULL, 10,
&graphics->data.vnc.port) < 0) {
@@ -722,11 +715,9 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
}
} else {
if (STRPREFIX(key, "display=")) {
- if (VIR_STRDUP(graphics->data.sdl.display, key + 8) < 0)
- goto cleanup;
+ graphics->data.sdl.display = g_strdup(key + 8);
} else if (STRPREFIX(key, "xauthority=")) {
- if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11) < 0)
- goto cleanup;
+ graphics->data.sdl.xauth = g_strdup(key + 11);
}
}
@@ -786,8 +777,7 @@ xenParseSxprChar(const char *value,
if (value[0] == '/') {
def->source->type = VIR_DOMAIN_CHR_TYPE_DEV;
- if (VIR_STRDUP(def->source->data.file.path, value) < 0)
- goto error;
+ def->source->data.file.path = g_strdup(value);
} else {
if ((tmp = strchr(value, ':')) != NULL) {
*tmp = '\0';
@@ -808,14 +798,12 @@ xenParseSxprChar(const char *value,
switch (def->source->type) {
case VIR_DOMAIN_CHR_TYPE_PTY:
- if (VIR_STRDUP(def->source->data.file.path, tty) < 0)
- goto error;
+ def->source->data.file.path = g_strdup(tty);
break;
case VIR_DOMAIN_CHR_TYPE_FILE:
case VIR_DOMAIN_CHR_TYPE_PIPE:
- if (VIR_STRDUP(def->source->data.file.path, value) < 0)
- goto error;
+ def->source->data.file.path = g_strdup(value);
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
@@ -877,11 +865,9 @@ xenParseSxprChar(const char *value,
offset2 + 1, offset3 - offset2 - 1) < 0)
goto error;
- if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1) < 0)
- goto error;
+ def->source->data.udp.bindService = g_strdup(offset3 + 1);
} else {
- if (VIR_STRDUP(def->source->data.udp.connectService, offset + 1) <
0)
- goto error;
+ def->source->data.udp.connectService = g_strdup(offset + 1);
}
}
break;
@@ -1034,10 +1020,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge)
if (!vlanstr_list)
return -1;
- if (VIR_STRDUP(net->data.bridge.brname, vlanstr_list[0]) < 0) {
- virStringListFree(vlanstr_list);
- return -1;
- }
+ net->data.bridge.brname = g_strdup(vlanstr_list[0]);
for (i = 1; vlanstr_list[i]; i++)
nvlans++;
@@ -1065,8 +1048,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge)
return 0;
} else {
/* 'bridge' string only contains the bridge name */
- if (VIR_STRDUP(net->data.bridge.brname, bridge) < 0)
- return -1;
+ net->data.bridge.brname = g_strdup(bridge);
}
return 0;
@@ -1086,8 +1068,7 @@ xenParseSxprVifRate(const char *rate, unsigned long long
*kbytes_per_sec)
unsigned long long tmp;
int ret = -1;
- if (VIR_STRDUP(trate, rate) < 0)
- return -1;
+ trate = g_strdup(rate);
p = strchr(trate, '@');
if (p != NULL)
@@ -1271,9 +1252,8 @@ xenParseVif(char *entry, const char *vif_typename)
virStringListFree(ip_list);
}
- if (script && script[0] &&
- VIR_STRDUP(net->script, script) < 0)
- goto cleanup;
+ if (script && script[0])
+ net->script = g_strdup(script);
if (model[0]) {
if (virDomainNetSetModelString(net, model) < 0)
@@ -1283,9 +1263,8 @@ xenParseVif(char *entry, const char *vif_typename)
net->model = VIR_DOMAIN_NET_MODEL_NETFRONT;
}
- if (vifname[0] &&
- VIR_STRDUP(net->ifname, vifname) < 0)
- goto cleanup;
+ if (vifname[0])
+ net->ifname = g_strdup(vifname);
if (rate[0]) {
virNetDevBandwidthPtr bandwidth;
@@ -1482,8 +1461,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr
caps)
goto out;
def->os.arch = capsdata->arch;
- if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)
- goto out;
+ def->os.machine = g_strdup(capsdata->machinetype);
ret = 0;
out:
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index cbd3364fe9..6bdad2a59d 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -78,8 +78,7 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
return -1;
if (buf) {
- if (VIR_STRDUP(cmdline, buf) < 0)
- return -1;
+ cmdline = g_strdup(buf);
if (root || extra)
VIR_WARN("ignoring root= and extra= in favour of cmdline=");
} else {
@@ -90,8 +89,7 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
if (virAsprintf(&cmdline, "root=%s", root) < 0)
return -1;
} else if (extra) {
- if (VIR_STRDUP(cmdline, extra) < 0)
- return -1;
+ cmdline = g_strdup(extra);
}
}
@@ -119,17 +117,14 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
- if (VIR_STRDUP(def->os.loader->path,
- LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0)
- return -1;
+ def->os.loader->path = g_strdup(LIBXL_FIRMWARE_DIR
"/ovmf.bin");
} else {
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM &&
caps->guests[i]->arch.id == def->os.arch) {
- if (VIR_ALLOC(def->os.loader) < 0 ||
- VIR_STRDUP(def->os.loader->path,
- caps->guests[i]->arch.defaultInfo.loader) <
0)
+ if (VIR_ALLOC(def->os.loader) < 0)
return -1;
+ def->os.loader->path =
g_strdup(caps->guests[i]->arch.defaultInfo.loader);
}
}
}
@@ -538,8 +533,7 @@ xenParseXLVnuma(virConfPtr conf,
}
VIR_FREE(tmp);
- if (VIR_STRDUP(tmp, vtoken) < 0)
- goto cleanup;
+ tmp = g_strdup(vtoken);
virStringListFree(token);
if (!(token = virStringSplitCount(tmp, ",", 0,
&ndistances)))
@@ -736,8 +730,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
if (xenParseXLDiskSrc(disk, libxldisk->pdev_path) < 0)
goto fail;
- if (VIR_STRDUP(disk->dst, libxldisk->vdev) < 0)
- goto fail;
+ disk->dst = g_strdup(libxldisk->vdev);
disk->src->readonly = !libxldisk->readwrite;
disk->removable = libxldisk->removable;
@@ -1376,8 +1369,7 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def)
if (VIR_ALLOC_N(cpuid_pairs, def->cpu->nfeatures + 2) < 0)
return -1;
- if (VIR_STRDUP(cpuid_pairs[0], "host") < 0)
- goto cleanup;
+ cpuid_pairs[0] = g_strdup("host");
j = 1;
for (i = 0; i < def->cpu->nfeatures; i++) {
@@ -1659,8 +1651,7 @@ xenFormatXLDiskSrc(virStorageSourcePtr src, char **srcstr)
case VIR_STORAGE_TYPE_BLOCK:
case VIR_STORAGE_TYPE_FILE:
case VIR_STORAGE_TYPE_DIR:
- if (VIR_STRDUP(*srcstr, src->path) < 0)
- return -1;
+ *srcstr = g_strdup(src->path);
break;
case VIR_STORAGE_TYPE_NETWORK:
@@ -1947,8 +1938,7 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr def)
lastdev = lastdev->next;
}
lastdev->type = VIR_CONF_STRING;
- if (VIR_STRDUP(lastdev->str, devtype) < 0)
- goto error;
+ lastdev->str = g_strdup(devtype);
}
}
if (usbdevices->list != NULL) {
diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c
index e368482cac..fdf4e1cd29 100644
--- a/src/libxl/xen_xm.c
+++ b/src/libxl/xen_xm.c
@@ -96,8 +96,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
if (virAsprintf(&def->os.cmdline, "root=%s", root) < 0)
return -1;
} else if (extra) {
- if (VIR_STRDUP(def->os.cmdline, extra) < 0)
- return -1;
+ def->os.cmdline = g_strdup(extra);
}
}
--
2.21.0