提交 10bca495 编写于 作者: R Radoslaw Biernacki 提交者: Michal Privoznik

util: Code simplification

Removing redundant sections of the code
Signed-off-by: NRadoslaw Biernacki <radoslaw.biernacki@linaro.org>
Signed-off-by: Ndann frazier <dann.frazier@canonical.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 6452e2f5
...@@ -1443,29 +1443,20 @@ int ...@@ -1443,29 +1443,20 @@ int
virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname, virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname,
int *vf) int *vf)
{ {
char *pf_sysfs_path = NULL, *vf_sysfs_path = NULL;
int ret = -1; int ret = -1;
*pfname = NULL; *pfname = NULL;
if (virNetDevGetPhysicalFunction(vfname, pfname) < 0) if (virNetDevGetPhysicalFunction(vfname, pfname) < 0)
return ret; return -1;
if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0)
goto cleanup;
if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0) if (virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf) < 0)
goto cleanup; goto cleanup;
ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf); ret = 0;
cleanup: cleanup:
if (ret < 0) if (ret < 0)
VIR_FREE(*pfname); VIR_FREE(*pfname);
VIR_FREE(vf_sysfs_path);
VIR_FREE(pf_sysfs_path);
return ret; return ret;
} }
...@@ -1861,13 +1852,9 @@ virNetDevSaveNetConfig(const char *linkdev, int vf, ...@@ -1861,13 +1852,9 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
* it to PF + VFname * it to PF + VFname
*/ */
if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0)
goto cleanup; goto cleanup;
pfDevName = pfDevOrig; pfDevName = pfDevOrig;
if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0)
goto cleanup;
} }
if (pfDevName) { if (pfDevName) {
...@@ -2019,13 +2006,9 @@ virNetDevReadNetConfig(const char *linkdev, int vf, ...@@ -2019,13 +2006,9 @@ virNetDevReadNetConfig(const char *linkdev, int vf,
* it to PF + VFname * it to PF + VFname
*/ */
if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf) < 0)
goto cleanup; goto cleanup;
pfDevName = pfDevOrig; pfDevName = pfDevOrig;
if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0)
goto cleanup;
} }
/* if there is a PF, it's now in pfDevName, and linkdev is either /* if there is a PF, it's now in pfDevName, and linkdev is either
...@@ -2224,13 +2207,9 @@ virNetDevSetNetConfig(const char *linkdev, int vf, ...@@ -2224,13 +2207,9 @@ virNetDevSetNetConfig(const char *linkdev, int vf,
* it to PF + VFname * it to PF + VFname
*/ */
if (virNetDevGetPhysicalFunction(linkdev, &pfDevOrig) < 0) if (virNetDevGetVirtualFunctionInfo(linkdev, &pfDevOrig, &vf))
goto cleanup; goto cleanup;
pfDevName = pfDevOrig; pfDevName = pfDevOrig;
if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, &vf) < 0)
goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册