]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainNetIPInfoParseXML: Remove pointless automatic clearing of 'route' and 'ip'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 15 Sep 2022 15:47:49 +0000 (17:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 3 Oct 2022 12:43:17 +0000 (14:43 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index 574d962a55f72dcc2dbdf601ac0fe022fa2041a5..292bd1937cfbc03d9ee54917204f0fb17fddfeab 100644 (file)
@@ -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;