util: Code simplification

Removing redundant sections of the code

Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Radoslaw Biernacki 2019-01-22 12:26:13 -07:00 committed by Michal Privoznik
parent 6452e2f5e1
commit 10bca495e0

View File

@ -1443,29 +1443,20 @@ int
virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname,
int *vf)
{
char *pf_sysfs_path = NULL, *vf_sysfs_path = NULL;
int ret = -1;
*pfname = NULL;
if (virNetDevGetPhysicalFunction(vfname, pfname) < 0)
return ret;
return -1;
if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0)
if (virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf) < 0)
goto cleanup;
if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0)
goto cleanup;
ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf);
ret = 0;
cleanup:
if (ret < 0)
VIR_FREE(*pfname);
VIR_FREE(vf_sysfs_path);
VIR_FREE(pf_sysfs_path);
return ret;
}
@ -1861,13 +1852,9 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
* it to PF + VFname
*/
if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0)
if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0)
goto cleanup;
pfDevName = pfDevOrig;
if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0)
goto cleanup;
}
if (pfDevName) {
@ -2019,13 +2006,9 @@ virNetDevReadNetConfig(const char *linkdev, int vf,
* it to PF + VFname
*/
if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0)
if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0)
goto cleanup;
pfDevName = pfDevOrig;
if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0)
goto cleanup;
}
/* if there is a PF, it's now in pfDevName, and linkdev is either
@ -2224,13 +2207,9 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
* it to PF + VFname
*/
if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0)
if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf))
goto cleanup;
pfDevName = pfDevOrig;
if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0)
goto cleanup;
}