[libvirt] [PATCH] remove unnecessary "V = NULL; " stmts after VIR_FREE(V)

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

 



Doing a review (in progress), I spotted one of these, so went in search of
others.  They're harmless, so this is more a heads up than anything else.
I am happy to defer application until the patch queue has been reduced.

>From d97af7667699529c216835d806d1f0c6f698a70d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 17 Jul 2008 12:05:44 +0200
Subject: [PATCH] remove unnecessary "V = NULL;" stmts after VIR_FREE(V)

* src/domain_conf.c (virDomainChrDefParseXML)
(virDomainNetDefParseXML): Likewise.
* src/iptables.c (iptRuleFree): Likewise.
* src/storage_backend.c (virStorageBackendRunProgRegex): Likewise.
* src/test.c (testOpenFromFile): Likewise.
* src/xm_internal.c (xenXMAttachInterface): Likewise.
* src/xml.c (virDomainParseXMLOSDescHVM): Likewise.
* src/xmlrpc.c (xmlRpcCallRaw): Likewise.
---
 src/domain_conf.c     |    5 +----
 src/iptables.c        |    2 --
 src/storage_backend.c |    4 +---
 src/test.c            |    8 ++------
 src/xm_internal.c     |    1 -
 src/xml.c             |    1 -
 src/xmlrpc.c          |    1 -
 7 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/domain_conf.c b/src/domain_conf.c
index 82c0ee6..6340c2a 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -696,7 +696,6 @@ virDomainNetDefParseXML(virConnectPtr conn,
                 if (STRPREFIX((const char*)ifname, "vnet")) {
                     /* An auto-generated target name, blank it out */
                     VIR_FREE(ifname);
-                    ifname = NULL;
                 }
             } else if ((script == NULL) &&
                        (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET) &&
@@ -954,10 +953,8 @@ virDomainChrDefParseXML(virConnectPtr conn,
                             bindService = virXMLPropString(cur, "service");
                     }

-                    if (def->type == VIR_DOMAIN_CHR_TYPE_UDP) {
+                    if (def->type == VIR_DOMAIN_CHR_TYPE_UDP)
                         VIR_FREE(mode);
-                        mode = NULL;
-                    }
                 }
             } else if (xmlStrEqual(cur->name, BAD_CAST "protocol")) {
                 if (protocol == NULL)
diff --git a/src/iptables.c b/src/iptables.c
index e7613e2..3e3a1a2 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -266,14 +266,12 @@ static void
 iptRuleFree(iptRule *rule)
 {
     VIR_FREE(rule->rule);
-    rule->rule = NULL;

     if (rule->argv) {
         int i = 0;
         while (rule->argv[i])
             VIR_FREE(rule->argv[i++]);
         VIR_FREE(rule->argv);
-        rule->argv = NULL;
     }
 }

diff --git a/src/storage_backend.c b/src/storage_backend.c
index 3e4e39c..a164a08 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -444,10 +444,8 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
                         goto cleanup;

                     /* Release matches & restart to matching the first regex */
-                    for (j = 0 ; j < totgroups ; j++) {
+                    for (j = 0 ; j < totgroups ; j++)
                         VIR_FREE(groups[j]);
-                        groups[j] = NULL;
-                    }
                     maxReg = 0;
                     ngroup = 0;
                 }
diff --git a/src/test.c b/src/test.c
index d0bb003..b7b9df0 100644
--- a/src/test.c
+++ b/src/test.c
@@ -461,10 +461,8 @@ static int testOpenFromFile(virConnectPtr conn,
         dom->def->id = privconn->nextDomID++;
         dom->persistent = 1;
     }
-    if (domains != NULL) {
+    if (domains != NULL)
         VIR_FREE(domains);
-        domains = NULL;
-    }

     ret = virXPathNodeSet("/node/network", ctxt, &networks);
     if (ret < 0) {
@@ -498,10 +496,8 @@ static int testOpenFromFile(virConnectPtr conn,

         net->persistent = 1;
     }
-    if (networks != NULL) {
+    if (networks != NULL)
         VIR_FREE(networks);
-        networks = NULL;
-    }

     xmlXPathFreeContext(ctxt);
     xmlFreeDoc(xml);
diff --git a/src/xm_internal.c b/src/xm_internal.c
index 3b264a8..60f32fe 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -2925,7 +2925,6 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm,
             if (virMacAddrCompare (dommac, (const char *) mac) == 0) {
                 if (autoassign) {
                     VIR_FREE(mac);
-                    mac = NULL;
                     if (!(mac = (xmlChar *)xenXMAutoAssignMac()))
                         goto cleanup;
                     /* initialize the list */
diff --git a/src/xml.c b/src/xml.c
index d5730ed..477d466 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1200,7 +1200,6 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
             xmlFree(bus);
         }
         VIR_FREE(nodes);
-        nodes = NULL;
     }

     cur = virXPathNode("/domain/devices/parallel[1]", ctxt);
diff --git a/src/xmlrpc.c b/src/xmlrpc.c
index d627607..cbca389 100644
--- a/src/xmlrpc.c
+++ b/src/xmlrpc.c
@@ -443,7 +443,6 @@ static char *xmlRpcCallRaw(const char *url, const char *request)
         if (ret != len) {
                 errno = EINVAL;
                 VIR_FREE(response);
-                response = NULL;
                 xmlRpcError(VIR_ERR_POST_FAILED, _("read response"), 0);
         }

--
1.5.6.3.385.g9f9af

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]