All the callers of these functions only check for a negative
return value.
However, virNetDevOpenvswitchGetVhostuserIfname is documented
as returning 1 for openvswitch interfaces so preserve that.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/esx/esx_vi.c | 3 ++-
src/esx/esx_vi_types.c | 6 ++----
src/qemu/qemu_alias.c | 21 ++++++++++++++-------
src/qemu/qemu_monitor_json.c | 3 ++-
src/storage/storage_util.c | 3 ++-
src/util/vircgroupv2.c | 6 ++++--
src/util/viriscsi.c | 6 ++++--
src/util/virnuma.c | 3 ++-
src/util/virresctrl.c | 3 ++-
src/util/virstoragefile.c | 3 ++-
src/util/viruri.c | 3 ++-
tests/qemuxml2argvmock.c | 6 ++++--
tests/securityselinuxhelper.c | 6 ++++--
13 files changed, 46 insertions(+), 26 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 004434c454..ef37bbf88d 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -2388,7 +2388,8 @@ esxVI_GetVirtualMachineMORef(esxVI_ObjectContent *virtualMachine,
if (virtualMachine->obj &&
STREQ(virtualMachine->obj->type, "VirtualMachine")
&&
virtualMachine->obj->value) {
- return VIR_STRDUP(*moref, virtualMachine->obj->value);
+ *moref = g_strdup(virtualMachine->obj->value);
+ return 0;
}
}
return -1;
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index deb6ebd09f..29b1b01b9b 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -1206,10 +1206,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
{
ESX_VI_CHECK_ARG_LIST(dest);
- if (!src)
- return 0;
-
- return VIR_STRDUP(*dest, src);
+ *dest = g_strdup(src);
+ return 0;
}
/* esxVI_String_CastFromAnyType */
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index 5af3725bf5..d4d8eb4252 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -134,7 +134,8 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
* hardcoded the name of their single PCI controller as
* "pci".
*/
- return VIR_STRDUP(controller->info.alias, "pci");
+ controller->info.alias = g_strdup("pci");
+ return 0;
} else if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
/* The pcie-root controller on Q35 machinetypes uses a
* different naming convention ("pcie.0"), because it is
@@ -153,18 +154,24 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
* controller hardcoded with id "ide"
*/
if (qemuDomainHasBuiltinIDE(domainDef) &&
- controller->idx == 0)
- return VIR_STRDUP(controller->info.alias, "ide");
+ controller->idx == 0) {
+ controller->info.alias = g_strdup("ide");
+ return 0;
+ }
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
/* for any Q35 machine, the first SATA controller is the
* integrated one, and it too is hardcoded with id "ide"
*/
- if (qemuDomainIsQ35(domainDef) && controller->idx == 0)
- return VIR_STRDUP(controller->info.alias, "ide");
+ if (qemuDomainIsQ35(domainDef) && controller->idx == 0) {
+ controller->info.alias = g_strdup("ide");
+ return 0;
+ }
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
/* first USB device is "usb", others are normal "usb%d" */
- if (controller->idx == 0)
- return VIR_STRDUP(controller->info.alias, "usb");
+ if (controller->idx == 0) {
+ controller->info.alias = g_strdup("usb");
+ return 0;
+ }
}
/* all other controllers use the default ${type}${index} naming
* scheme for alias/id.
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 4b765da0b1..602a0380d7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5957,7 +5957,8 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
return -1;
}
- return VIR_STRDUP(*result, data_result);
+ *result = g_strdup(data_result);
+ return 0;
}
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index a4c8a5e971..692b3e7a9d 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -2072,7 +2072,8 @@ virStorageBackendVolCreateLocal(virStoragePoolObjPtr pool,
}
VIR_FREE(vol->key);
- return VIR_STRDUP(vol->key, vol->target.path);
+ vol->key = g_strdup(vol->target.path);
+ return 0;
}
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 621ab71eb5..7a64e74c3a 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -146,7 +146,8 @@ static int
virCgroupV2CopyMounts(virCgroupPtr group,
virCgroupPtr parent)
{
- return VIR_STRDUP(group->unified.mountPoint, parent->unified.mountPoint);
+ group->unified.mountPoint = g_strdup(parent->unified.mountPoint);
+ return 0;
}
@@ -189,7 +190,8 @@ virCgroupV2DetectMounts(virCgroupPtr group,
VIR_FREE(group->unified.mountPoint);
- return VIR_STRDUP(group->unified.mountPoint, mntDir);
+ group->unified.mountPoint = g_strdup(mntDir);
+ return 0;
}
diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index dc553e7752..1b143ec61f 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -60,8 +60,10 @@ virISCSIExtractSession(char **const groups,
struct virISCSISessionData *data = opaque;
if (!data->session &&
- STREQ(groups[1], data->devpath))
- return VIR_STRDUP(data->session, groups[0]);
+ STREQ(groups[1], data->devpath)) {
+ data->session = g_strdup(groups[0]);
+ return 0;
+ }
return 0;
}
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 8f50634c2a..448833d8d1 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -579,7 +579,8 @@ static int
virNumaGetHugePageInfoDir(char **path, int node)
{
if (node == -1) {
- return VIR_STRDUP(*path, HUGEPAGES_SYSTEM_PREFIX);
+ *path = g_strdup(HUGEPAGES_SYSTEM_PREFIX);
+ return 0;
} else {
return virAsprintf(path,
HUGEPAGES_NUMA_PREFIX "node%d/hugepages/",
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index ab650b59b9..e52408ed06 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -1388,7 +1388,8 @@ virResctrlSetID(char **resctrlid,
return -1;
}
- return VIR_STRDUP(*resctrlid, id);
+ *resctrlid = g_strdup(id);
+ return 0;
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 64e09d7951..c13ed9fee5 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -4468,7 +4468,8 @@ int
virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest,
const virStorageSourceInitiatorDef *src)
{
- return VIR_STRDUP(dest->iqn, src->iqn);
+ dest->iqn = g_strdup(src->iqn);
+ return 0;
}
void
diff --git a/src/util/viruri.c b/src/util/viruri.c
index a43fe2afd4..af2e828c28 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -350,7 +350,8 @@ virURIFindAliasMatch(char *const*aliases, const char *alias,
STREQLEN(*aliases, alias, alias_len)) {
VIR_DEBUG("Resolved alias '%s' to '%s'",
alias, offset+1);
- return VIR_STRDUP(*uri, offset+1);
+ *uri = g_strdup(offset + 1);
+ return 0;
}
aliases++;
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 2b9e5e7a49..34e0eb91a6 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -153,7 +153,8 @@ virNetDevTapCreate(char **ifname,
return 0;
} else {
VIR_FREE(*ifname);
- return VIR_STRDUP(*ifname, "vnet0");
+ *ifname = g_strdup("vnet0");
+ return 0;
}
}
@@ -229,7 +230,8 @@ int
virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED,
char **ifname)
{
- return VIR_STRDUP(*ifname, "vhost-user0");
+ *ifname = g_strdup("vhost-user0");
+ return 1;
}
int
diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c
index 6391f67360..814250b731 100644
--- a/tests/securityselinuxhelper.c
+++ b/tests/securityselinuxhelper.c
@@ -111,7 +111,8 @@ int getcon_raw(security_context_t *context)
errno = EINVAL;
return -1;
}
- return VIR_STRDUP_QUIET(*context, getenv("FAKE_SELINUX_CONTEXT"));
+ *context = g_strdup(getenv("FAKE_SELINUX_CONTEXT"));
+ return 0;
}
int getcon(security_context_t *context)
@@ -135,7 +136,8 @@ int getpidcon_raw(pid_t pid, security_context_t *context)
errno = EINVAL;
return -1;
}
- return VIR_STRDUP_QUIET(*context, getenv("FAKE_SELINUX_CONTEXT"));
+ *context = g_strdup(getenv("FAKE_SELINUX_CONTEXT"));
+ return 0;
}
int getpidcon(pid_t pid, security_context_t *context)
--
2.21.0