mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
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: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
94c98eb550
commit
3cbd4351de
@ -2388,7 +2388,8 @@ esxVI_GetVirtualMachineMORef(esxVI_ObjectContent *virtualMachine,
|
|||||||
if (virtualMachine->obj &&
|
if (virtualMachine->obj &&
|
||||||
STREQ(virtualMachine->obj->type, "VirtualMachine") &&
|
STREQ(virtualMachine->obj->type, "VirtualMachine") &&
|
||||||
virtualMachine->obj->value) {
|
virtualMachine->obj->value) {
|
||||||
return VIR_STRDUP(*moref, virtualMachine->obj->value);
|
*moref = g_strdup(virtualMachine->obj->value);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1206,10 +1206,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src)
|
|||||||
{
|
{
|
||||||
ESX_VI_CHECK_ARG_LIST(dest);
|
ESX_VI_CHECK_ARG_LIST(dest);
|
||||||
|
|
||||||
if (!src)
|
*dest = g_strdup(src);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return VIR_STRDUP(*dest, src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* esxVI_String_CastFromAnyType */
|
/* esxVI_String_CastFromAnyType */
|
||||||
|
@ -134,7 +134,8 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
|
|||||||
* hardcoded the name of their single PCI controller as
|
* hardcoded the name of their single PCI controller as
|
||||||
* "pci".
|
* "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) {
|
} else if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
|
||||||
/* The pcie-root controller on Q35 machinetypes uses a
|
/* The pcie-root controller on Q35 machinetypes uses a
|
||||||
* different naming convention ("pcie.0"), because it is
|
* different naming convention ("pcie.0"), because it is
|
||||||
@ -153,18 +154,24 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef,
|
|||||||
* controller hardcoded with id "ide"
|
* controller hardcoded with id "ide"
|
||||||
*/
|
*/
|
||||||
if (qemuDomainHasBuiltinIDE(domainDef) &&
|
if (qemuDomainHasBuiltinIDE(domainDef) &&
|
||||||
controller->idx == 0)
|
controller->idx == 0) {
|
||||||
return VIR_STRDUP(controller->info.alias, "ide");
|
controller->info.alias = g_strdup("ide");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
|
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) {
|
||||||
/* for any Q35 machine, the first SATA controller is the
|
/* for any Q35 machine, the first SATA controller is the
|
||||||
* integrated one, and it too is hardcoded with id "ide"
|
* integrated one, and it too is hardcoded with id "ide"
|
||||||
*/
|
*/
|
||||||
if (qemuDomainIsQ35(domainDef) && controller->idx == 0)
|
if (qemuDomainIsQ35(domainDef) && controller->idx == 0) {
|
||||||
return VIR_STRDUP(controller->info.alias, "ide");
|
controller->info.alias = g_strdup("ide");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
|
} else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
|
||||||
/* first USB device is "usb", others are normal "usb%d" */
|
/* first USB device is "usb", others are normal "usb%d" */
|
||||||
if (controller->idx == 0)
|
if (controller->idx == 0) {
|
||||||
return VIR_STRDUP(controller->info.alias, "usb");
|
controller->info.alias = g_strdup("usb");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* all other controllers use the default ${type}${index} naming
|
/* all other controllers use the default ${type}${index} naming
|
||||||
* scheme for alias/id.
|
* scheme for alias/id.
|
||||||
|
@ -5957,7 +5957,8 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
|
|||||||
return -1;
|
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);
|
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,
|
virCgroupV2CopyMounts(virCgroupPtr group,
|
||||||
virCgroupPtr parent)
|
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);
|
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;
|
struct virISCSISessionData *data = opaque;
|
||||||
|
|
||||||
if (!data->session &&
|
if (!data->session &&
|
||||||
STREQ(groups[1], data->devpath))
|
STREQ(groups[1], data->devpath)) {
|
||||||
return VIR_STRDUP(data->session, groups[0]);
|
data->session = g_strdup(groups[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +579,8 @@ static int
|
|||||||
virNumaGetHugePageInfoDir(char **path, int node)
|
virNumaGetHugePageInfoDir(char **path, int node)
|
||||||
{
|
{
|
||||||
if (node == -1) {
|
if (node == -1) {
|
||||||
return VIR_STRDUP(*path, HUGEPAGES_SYSTEM_PREFIX);
|
*path = g_strdup(HUGEPAGES_SYSTEM_PREFIX);
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return virAsprintf(path,
|
return virAsprintf(path,
|
||||||
HUGEPAGES_NUMA_PREFIX "node%d/hugepages/",
|
HUGEPAGES_NUMA_PREFIX "node%d/hugepages/",
|
||||||
|
@ -1388,7 +1388,8 @@ virResctrlSetID(char **resctrlid,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return VIR_STRDUP(*resctrlid, id);
|
*resctrlid = g_strdup(id);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4468,7 +4468,8 @@ int
|
|||||||
virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest,
|
virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest,
|
||||||
const virStorageSourceInitiatorDef *src)
|
const virStorageSourceInitiatorDef *src)
|
||||||
{
|
{
|
||||||
return VIR_STRDUP(dest->iqn, src->iqn);
|
dest->iqn = g_strdup(src->iqn);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -350,7 +350,8 @@ virURIFindAliasMatch(char *const*aliases, const char *alias,
|
|||||||
STREQLEN(*aliases, alias, alias_len)) {
|
STREQLEN(*aliases, alias, alias_len)) {
|
||||||
VIR_DEBUG("Resolved alias '%s' to '%s'",
|
VIR_DEBUG("Resolved alias '%s' to '%s'",
|
||||||
alias, offset+1);
|
alias, offset+1);
|
||||||
return VIR_STRDUP(*uri, offset+1);
|
*uri = g_strdup(offset + 1);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
aliases++;
|
aliases++;
|
||||||
|
@ -153,7 +153,8 @@ virNetDevTapCreate(char **ifname,
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
VIR_FREE(*ifname);
|
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,
|
virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED,
|
||||||
char **ifname)
|
char **ifname)
|
||||||
{
|
{
|
||||||
return VIR_STRDUP(*ifname, "vhost-user0");
|
*ifname = g_strdup("vhost-user0");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -111,7 +111,8 @@ int getcon_raw(security_context_t *context)
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
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)
|
int getcon(security_context_t *context)
|
||||||
@ -135,7 +136,8 @@ int getpidcon_raw(pid_t pid, security_context_t *context)
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
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)
|
int getpidcon(pid_t pid, security_context_t *context)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user