[PATCH 2/4] lib: Don't set variable to NULL after VIR_FREE()

Michal Privoznik mprivozn at redhat.com
Mon Jan 31 14:53:40 UTC 2022


There are a few places where a variable is VIR_FREE()-d and then
explicitly set to NULL. This is not necessary since VIR_FREE()
does that for us.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/domain_conf.c    | 1 -
 src/conf/nwfilter_conf.c  | 1 -
 tests/virtypedparamtest.c | 1 -
 3 files changed, 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 58e696416d..e931aef6c4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12746,7 +12746,6 @@ virDomainGraphicsDefNew(virDomainXMLOption *xmlopt)
     if (xmlopt && xmlopt->privateData.graphicsNew &&
         !(def->privateData = xmlopt->privateData.graphicsNew())) {
         VIR_FREE(def);
-        def = NULL;
     }
 
     return def;
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 3fedfdde56..c886218dde 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -1813,7 +1813,6 @@ virNWFilterRuleDetailsParse(xmlNodePtr node,
     if (match && STREQ(match, "no"))
         match_flag = NWFILTER_ENTRY_ITEM_FLAG_IS_NEG;
     VIR_FREE(match);
-    match = NULL;
 
     while (att[idx].name != NULL) {
         prop = virXMLPropString(node, att[idx].name);
diff --git a/tests/virtypedparamtest.c b/tests/virtypedparamtest.c
index 87b47ba86e..5ced453be5 100644
--- a/tests/virtypedparamtest.c
+++ b/tests/virtypedparamtest.c
@@ -106,7 +106,6 @@ testTypedParamsFilter(const void *opaque G_GNUC_UNUSED)
             goto cleanup;
     }
     VIR_FREE(filtered);
-    filtered = NULL;
 
     nfiltered = virTypedParamsFilter(params, G_N_ELEMENTS(params),
                                      "bar", &filtered);
-- 
2.34.1




More information about the libvir-list mailing list