提交 3cbd4351 编写于 作者: J Ján Tomko

Use g_strdup where VIR_STRDUP's return value was propagated

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: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 94c98eb5
......@@ -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;
......
......@@ -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 */
......
......@@ -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.
......
......@@ -5957,7 +5957,8 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
return -1;
}
return VIR_STRDUP(*result, data_result);
*result = g_strdup(data_result);
return 0;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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/",
......
......@@ -1388,7 +1388,8 @@ virResctrlSetID(char **resctrlid,
return -1;
}
return VIR_STRDUP(*resctrlid, id);
*resctrlid = g_strdup(id);
return 0;
}
......
......@@ -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
......
......@@ -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++;
......
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册