[libvirt] [PATCH v2 02/12] Fix build errors on FreeBSD

Ryan Moeller ryan at ixsystems.com
Thu Jan 2 17:46:25 UTC 2020


From: Ryan Moeller <ryan at freqlabs.com>

Don't free the file string until after it has been used to print the
error message.

Simplify PCI bus parsing to eliminate an unannotated switch fallthrough.

Signed-off-by: Ryan Moeller <ryan at iXsystems.com>
---
 src/conf/virnetworkobj.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 5daf4a8cb1..5c45f49be0 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1895,13 +1895,14 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net,
         file = g_strdup_printf("%s/%s.xml", dir, de->d_name);
 
         portdef = virNetworkPortDefParseFile(file);
-        VIR_FREE(file);
-        file = NULL;
-
         if (!portdef) {
             VIR_WARN("Cannot parse port %s", file);
+            VIR_FREE(file);
+            file = NULL;
             continue;
         }
+        VIR_FREE(file);
+        file = NULL;
 
         virUUIDFormat(portdef->uuid, uuidstr);
         if (virHashAddEntry(net->ports, uuidstr, portdef) < 0)
-- 
2.23.0





More information about the libvir-list mailing list