1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virPCIGetVirtualFunctionIndex: Refactor cleanup

The 'ret' variable and 'out' label can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-08-04 16:35:31 +02:00
parent c97518d9b8
commit 9766d0bac7

View File

@ -2409,31 +2409,28 @@ virPCIGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
const char *vf_sysfs_device_link, const char *vf_sysfs_device_link,
int *vf_index) int *vf_index)
{ {
int ret = -1;
size_t i; size_t i;
g_autofree virPCIDeviceAddress *vf_bdf = NULL; g_autofree virPCIDeviceAddress *vf_bdf = NULL;
g_autoptr(virPCIVirtualFunctionList) virt_fns = NULL; g_autoptr(virPCIVirtualFunctionList) virt_fns = NULL;
if (!(vf_bdf = virPCIGetDeviceAddressFromSysfsLink(vf_sysfs_device_link))) if (!(vf_bdf = virPCIGetDeviceAddressFromSysfsLink(vf_sysfs_device_link)))
return ret; return -1;
if (virPCIGetVirtualFunctions(pf_sysfs_device_link, &virt_fns) < 0) { if (virPCIGetVirtualFunctions(pf_sysfs_device_link, &virt_fns) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Error getting physical function's '%s' " _("Error getting physical function's '%s' "
"virtual_functions"), pf_sysfs_device_link); "virtual_functions"), pf_sysfs_device_link);
goto out; return -1;
} }
for (i = 0; i < virt_fns->nfunctions; i++) { for (i = 0; i < virt_fns->nfunctions; i++) {
if (virPCIDeviceAddressEqual(vf_bdf, virt_fns->functions[i].addr)) { if (virPCIDeviceAddressEqual(vf_bdf, virt_fns->functions[i].addr)) {
*vf_index = i; *vf_index = i;
ret = 0; return 0;
break;
} }
} }
out: return -1;
return ret;
} }
/* /*