[PATCH 2/5] bridge_driver: Use g_autoptr() for virMacMap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Let's annotate virMacMap variables in bridge_driver.c with
g_autoptr() so that they are automatically freed upon error. This
may look like a needless commit, since there's no memory leak
currently, but it simplifies the next commit.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 7ad9f278a2..a07af55390 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -450,7 +450,7 @@ networkUpdateState(virNetworkObj *obj,
     virNetworkDef *def;
     virNetworkDriverState *driver = opaque;
     g_autoptr(dnsmasqCaps) dnsmasq_caps = networkGetDnsmasqCaps(driver);
-    virMacMap *macmap;
+    g_autoptr(virMacMap) macmap = NULL;
     g_autofree char *macMapFile = NULL;
     VIR_LOCK_GUARD lock = virObjectLockGuard(obj);
 
@@ -476,6 +476,7 @@ networkUpdateState(virNetworkObj *obj,
             return -1;
 
         virNetworkObjSetMacMap(obj, macmap);
+        macmap = NULL;
 
         break;
 
@@ -1938,7 +1939,7 @@ networkStartNetworkVirtual(virNetworkDriverState *driver,
     virErrorPtr save_err = NULL;
     virNetworkIPDef *ipdef;
     virNetDevIPRoute *routedef;
-    virMacMap *macmap;
+    g_autoptr(virMacMap) macmap = NULL;
     g_autofree char *macMapFile = NULL;
     bool dnsmasqStarted = false;
     bool devOnline = false;
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux