[PATCH 08/37] virDomainNetIPInfoParseXML: Remove pointless automatic clearing of 'route' and 'ip'

Peter Krempa pkrempa at redhat.com
Mon Sep 19 08:54:53 UTC 2022


The variables are only used in code paths which can't fail after they
are allocated.

Additionally decrease scope of the variables.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 745a7e428c..5c91cbd0db 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6216,17 +6216,17 @@ virDomainNetIPInfoParseXML(const char *source,
                            xmlXPathContextPtr ctxt,
                            virNetDevIPInfo *def)
 {
-    g_autoptr(virNetDevIPRoute) route = NULL;
     int nnodes;
     int ret = -1;
     size_t i;
     g_autofree xmlNodePtr *nodes = NULL;
-    g_autofree virNetDevIPAddr *ip = NULL;

     if ((nnodes = virXPathNodeSet("./ip", ctxt, &nodes)) < 0)
         goto cleanup;

     for (i = 0; i < nnodes; i++) {
+        virNetDevIPAddr *ip = NULL;
+
         if (!(ip = virDomainNetIPParseXML(nodes[i])))
             goto cleanup;

@@ -6238,6 +6238,8 @@ virDomainNetIPInfoParseXML(const char *source,
         goto cleanup;

     for (i = 0; i < nnodes; i++) {
+        virNetDevIPRoute *route = NULL;
+
         if (!(route = virNetDevIPRouteParseXML(source, nodes[i], ctxt)))
             goto cleanup;

-- 
2.37.1



More information about the libvir-list mailing list