[libvirt] [PATCH 1/3] virPCIGetNetName: Initialize @netname to NULL

Michal Privoznik mprivozn at redhat.com
Wed Jan 23 15:45:06 UTC 2019


This is a return argument that is to be compared against NULL on
successful return. However, it is not initialized and therefore
relies on callers setting it to NULL prior calling the function.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virnetdev.c | 2 --
 src/util/virpci.c    | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 92ef008ca1..f3e3d442ed 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1445,8 +1445,6 @@ virNetDevGetVirtualFunctionInfo(const char *vfname, char **pfname,
 {
     int ret = -1;
 
-    *pfname = NULL;
-
     if (virNetDevGetPhysicalFunction(vfname, pfname) < 0)
         return -1;
 
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 537876bcba..ef578bf774 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2853,6 +2853,8 @@ virPCIGetNetName(const char *device_link_sysfs_path,
     struct dirent *entry = NULL;
     size_t i = 0;
 
+    *netname = NULL;
+
     if (virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path,
                      "net") == -1) {
         virReportOOMError();
-- 
2.19.2




More information about the libvir-list mailing list