diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cd9b6ca993842f4aa336a1772cded79039766c33..d0dd7b3fa9fae692b096a812255283c30fec70f4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13140,8 +13140,8 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt, switch (def->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: path = virXPathString("string(./backend/device/@path)", ctxt); - if (!path && VIR_STRDUP(path, VIR_DOMAIN_TPM_DEFAULT_DEVICE) < 0) - goto error; + if (!path) + path = g_strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE); def->data.passthrough.source.data.file.path = g_steal_pointer(&path); def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV; break; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 9e4978b560580315f0e8324d36eb967d029a1689..ba3e3ec326d9ac9bf7fc258c6879c8ed1ef9298f 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1414,8 +1414,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, if ((n = virXPathNodeSet("./target/features/*", ctxt, &nodes)) < 0) return NULL; - if (!def->target.compat && VIR_STRDUP(def->target.compat, "1.1") < 0) - return NULL; + if (!def->target.compat) + def->target.compat = g_strdup("1.1"); if (!(def->target.features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST))) return NULL; diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index d7210375fa7d519d0e473bbe8230aa40c9471698..1bed01054bbd0294701ca3133ea97b596e6b7edc 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -156,9 +156,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri) if (VIR_STRDUP((*parsedUri)->path, uri->path) < 0) goto cleanup; - if (!(*parsedUri)->transport && - VIR_STRDUP((*parsedUri)->transport, "https") < 0) - goto cleanup; + if (!(*parsedUri)->transport) + (*parsedUri)->transport = g_strdup("https"); result = 0; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 29b1b01b9bf32ed01e305238d5fa7e101c4696cc..a32f674740ec5ce52bce14043b8cecaa5242b988 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1034,8 +1034,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) (*anyType)->value = (char *)xmlNodeListGetString(node->doc, node->children, 1); - if (!(*anyType)->value && VIR_STRDUP((*anyType)->value, "") < 0) - goto failure; + if (!(*anyType)->value) + (*anyType)->value = g_strdup(""); #define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \ do { \ diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c index 73b32694a1ff4d35b7408cbe2f2102b3f1c22d13..3b8471342680a145418494695453f9f2f8f655a9 100644 --- a/src/hyperv/hyperv_util.c +++ b/src/hyperv/hyperv_util.c @@ -71,9 +71,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) } } - if (!(*parsedUri)->transport && - VIR_STRDUP((*parsedUri)->transport, "https") < 0) - goto cleanup; + if (!(*parsedUri)->transport) + (*parsedUri)->transport = g_strdup("https"); result = 0; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index c9449ace9ecfc29d29cde4f69e95f031b7f8693d..84f69da8ded082f92875e1f1d57eef708af10289 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1307,8 +1307,8 @@ udevSetParent(struct udev_device *device, } while (def->parent == NULL && parent_device != NULL); - if (!def->parent && VIR_STRDUP(def->parent, "computer") < 0) - goto cleanup; + if (!def->parent) + def->parent = g_strdup("computer"); ret = 0; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 03093fd73b17bccbd96377a0285169975d56efc3..c264edddd79e59b608dc53990c595bf174a3d14e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3735,9 +3735,8 @@ virQEMUCapsLoadCache(virArch hostArch, if (virXPathBoolean("boolean(./package)", ctxt) > 0) { qemuCaps->package = virXPathString("string(./package)", ctxt); - if (!qemuCaps->package && - VIR_STRDUP(qemuCaps->package, "") < 0) - goto cleanup; + if (!qemuCaps->package) + qemuCaps->package = g_strdup(""); } if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3ef84cc9a6c9fcda81d353951758564a8afd1284..ab13eebd399d818957783fe19c3e2db1037213e1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13339,9 +13339,8 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg, mount_options = qemuSecurityGetMountOptions(mgr, vm->def); - if (!mount_options && - VIR_STRDUP(mount_options, "") < 0) - goto cleanup; + if (!mount_options) + mount_options = g_strdup(""); /* * tmpfs is limited to 64kb, since we only have device nodes in there diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bf301919cc7031ea3001ef2eeb0d1274526d46b8..5b42bbfd481f25e409d7e045ea9ff5f2a1626ac2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3574,8 +3574,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, } /* ifname: check if it's set in newdev. If not, retain the autogenerated one */ - if (!newdev->ifname && VIR_STRDUP(newdev->ifname, olddev->ifname) < 0) - goto cleanup; + if (!newdev->ifname) + newdev->ifname = g_strdup(olddev->ifname); if (STRNEQ_NULLABLE(olddev->ifname, newdev->ifname)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device tap name")); @@ -3603,9 +3603,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } /* grab alias from olddev if not set in newdev */ - if (!newdev->info.alias && - VIR_STRDUP(newdev->info.alias, olddev->info.alias) < 0) - goto cleanup; + if (!newdev->info.alias) + newdev->info.alias = g_strdup(olddev->info.alias); /* device alias is checked already in virDomainDefCompatibleDevice */ @@ -3617,9 +3616,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } - if (!newdev->info.romfile && - VIR_STRDUP(newdev->info.romfile, olddev->info.romfile) < 0) - goto cleanup; + if (!newdev->info.romfile) + newdev->info.romfile = g_strdup(olddev->info.romfile); if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network rom file")); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9228c7d0edc4821a4953bd084b1f547bacabff52..c22b2571970a83765e674a93768f521a151e60cd 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1247,8 +1247,8 @@ doRemoteOpen(virConnectPtr conn, break; case REMOTE_DRIVER_TRANSPORT_SSH: - if (!command && VIR_STRDUP(command, "ssh") < 0) - goto failed; + if (!command) + command = g_strdup("ssh"); if (!(priv->client = virNetClientNewSSH(priv->hostname, port, diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index dd8f7d3808f3400aeec0759e024d9af27a39dc18..82826d193cab43081d0aaacfbfa0010cffb1966d 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -459,8 +459,8 @@ AppArmorGenSecurityLabel(virSecurityManagerPtr mgr G_GNUC_UNUSED, if (VIR_STRDUP(secdef->imagelabel, profile_name) < 0) goto err; - if (!secdef->model && VIR_STRDUP(secdef->model, SECURITY_APPARMOR_NAME) < 0) - goto err; + if (!secdef->model) + secdef->model = g_strdup(SECURITY_APPARMOR_NAME); /* Now that we have a label, load the profile into the kernel. */ if (load_profile(mgr, secdef->label, def, NULL, false) < 0) { diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 4988659044beaf262bc1f517b155e71b688e833d..c24a63afd6f351a400ecbaa3ae364126922fc990 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -938,9 +938,8 @@ virSecuritySELinuxGenLabel(virSecurityManagerPtr mgr, if (!seclabel->imagelabel) goto cleanup; - if (!seclabel->model && - VIR_STRDUP(seclabel->model, SECURITY_SELINUX_NAME) < 0) - goto cleanup; + if (!seclabel->model) + seclabel->model = g_strdup(SECURITY_SELINUX_NAME); rc = 0; @@ -3368,8 +3367,8 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr, return NULL; } - if (!opts && VIR_STRDUP(opts, "") < 0) - return NULL; + if (!opts) + opts = g_strdup(""); VIR_DEBUG("imageLabel=%s opts=%s", secdef ? secdef->imagelabel : "(null)", opts); diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 5de21103f528aad256502ed1b7897872d21c40e4..80d2dfd0b4c1173d6fd0f6aeeb67445b03fac0f9 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -325,8 +325,8 @@ virStorageBackendLogicalMakeVol(char **const groups, vol->target.backingStore->type = VIR_STORAGE_TYPE_BLOCK; } - if (!vol->key && VIR_STRDUP(vol->key, groups[2]) < 0) - goto cleanup; + if (!vol->key) + vol->key = g_strdup(groups[2]); if (virStorageBackendUpdateVolInfo(vol, false, VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c index 6bfff9f5dd1fd9bc13befdf125ade6eedd5dcfac..75edab4b2609009b22144955720632804d55fd6a 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -136,8 +136,8 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, goto cleanup; } - if (!volume->key && VIR_STRDUP(volume->key, tokens[0]) < 0) - goto cleanup; + if (!volume->key) + volume->key = g_strdup(tokens[0]); if (volume->target.path == NULL) { if (virAsprintf(&volume->target.path, "%s/%s", diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bd095604c76e8b5551afc7c78a40ce21937437e1..6af40ee35c605729e3cdd798d31aae8c55ef231d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1100,8 +1100,8 @@ testOpenVolumesForPool(const char *file, return -1; } - if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) < 0) - return -1; + if (!volDef->key) + volDef->key = g_strdup(volDef->target.path); if (virStoragePoolObjAddVol(obj, volDef) < 0) return -1; diff --git a/src/util/virfile.c b/src/util/virfile.c index 15713a58d9f2f36cb5ebcf66a7d0890ce00474cc..6a26d4838c3e7e74ac2f3ddb310f26594579e6c4 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4008,12 +4008,12 @@ virFileComparePaths(const char *p1, const char *p2) * comparison. */ ignore_value(virFileResolveLink(p1, &res1)); - if (!res1 && VIR_STRDUP(res1, p1) < 0) - return -1; + if (!res1) + res1 = g_strdup(p1); ignore_value(virFileResolveLink(p2, &res2)); - if (!res2 && VIR_STRDUP(res2, p2) < 0) - return -1; + if (!res2) + res2 = g_strdup(p2); return STREQ_NULLABLE(res1, res2); } diff --git a/src/util/virlease.c b/src/util/virlease.c index a49bd5b9fbfff8158f3500a48a8613cbabc468e7..3d851eb808f7d9b8430f6e9bb434fd9fb1846dfa 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -106,12 +106,8 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new, /* This is an ipv6 lease */ if ((server_duid_tmp = virJSONValueObjectGetString(lease_tmp, "server-duid"))) { - if (!*server_duid && VIR_STRDUP(*server_duid, server_duid_tmp) < 0) { - /* Control reaches here when the 'action' is not for an - * ipv6 lease or, for some weird reason the env var - * DNSMASQ_SERVER_DUID wasn't set*/ - return -1; - } + if (!*server_duid) + *server_duid = g_strdup(server_duid_tmp); } else { /* Inject server-duid into those ipv6 leases which * didn't have it previously, for example, those diff --git a/src/util/virpci.c b/src/util/virpci.c index 2c54c8baa1af7ddb6c9fda9f59b2bed72ddf39f6..59a93a5e81b0980b3b8530c19806d523bfd2741e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2493,10 +2493,8 @@ virPCIGetNetName(const char *device_link_sysfs_path, * needed because some NIC drivers (e.g. i40e) * implement phys_port_id for PFs, but not for VFs */ - if (!firstEntryName && - VIR_STRDUP(firstEntryName, entry->d_name) < 0) { - goto cleanup; - } + if (!firstEntryName) + firstEntryName = g_strdup(entry->d_name); continue; } diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index c2dadfd41095116578daa154c71ebf1001058a16..db440611dc73f70b087335db879b1d00195b2390 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -240,8 +240,8 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr param, param->value.s = va_arg(ap, char *); } - if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0) - return -1; + if (!param->value.s) + param->value.s = g_strdup(""); break; default: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 7d20351a837ec223a4fe3aa8f9094d34efdc76aa..c9a80ba35d49575000b5b5b0419bcb0e629fba61 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2659,8 +2659,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) true) < 0) goto cleanup; - if (!networkName && VIR_STRDUP(networkName, "") < 0) - goto cleanup; + if (!networkName) + networkName = g_strdup(""); } /* vmx:vnet -> def:data.ifname */ diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index db14114cba9ff86441f9ce476d24c79e939e8f0d..07bc99cc03a4803c179d441d31ef6e69c9f069af 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -100,10 +100,8 @@ fillQemuCaps(virDomainCapsPtr domCaps, goto cleanup; } - if (!domCaps->machine && - VIR_STRDUP(domCaps->machine, - virQEMUCapsGetPreferredMachine(qemuCaps)) < 0) - goto cleanup; + if (!domCaps->machine) + domCaps->machine = g_strdup(virQEMUCapsGetPreferredMachine(qemuCaps)); if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, false,