diff mbox series

[2/4] util: Code simplification

Message ID 20181110125624.1168-3-radoslaw.biernacki@linaro.org
State Superseded
Headers show
Series util: Fixing libvirt errors on cavium/thunder-nicvf | expand

Commit Message

Radoslaw Biernacki Nov. 10, 2018, 12:56 p.m. UTC
Removing redundant sections of the code

Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>

---
 src/util/virnetdev.c | 40 +++-----------------
 1 file changed, 5 insertions(+), 35 deletions(-)

-- 
2.14.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Michal Prívozník Nov. 15, 2018, 11:23 a.m. UTC | #1
On 11/10/2018 01:56 PM, Radoslaw Biernacki wrote:
> Removing redundant sections of the code

> 

> Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>

> ---

>  src/util/virnetdev.c | 40 +++-----------------

>  1 file changed, 5 insertions(+), 35 deletions(-)


ACK

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index e55c538a29..117ec41869 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1445,30 +1445,12 @@  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;
-
-    if (virNetDevSysfsFile(&pf_sysfs_path, *pfname, "device") < 0)
-        goto cleanup;
-
-    if (virNetDevSysfsFile(&vf_sysfs_path, vfname, "device") < 0)
-        goto cleanup;
-
-    ret = virPCIGetVirtualFunctionIndex(pf_sysfs_path, vf_sysfs_path, vf);
-
- cleanup:
-    if (ret < 0)
-        VIR_FREE(*pfname);
-
-    VIR_FREE(vf_sysfs_path);
-    VIR_FREE(pf_sysfs_path);
+        return -1;
 
-    return ret;
+    return virNetDevGetVirtualFunctionIndex(*pfname, vfname, vf);
 }
 
 #else /* !__linux__ */
@@ -1863,13 +1845,9 @@  virNetDevSaveNetConfig(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;
     }
 
     if (pfDevName) {
@@ -2021,13 +1999,9 @@  virNetDevReadNetConfig(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;
     }
 
     /* if there is a PF, it's now in pfDevName, and linkdev is either
@@ -2226,13 +2200,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;
     }