[libvirt PATCH 5/5] vsh: use g_clear_pointer

Ján Tomko jtomko at redhat.com
Tue Aug 10 17:14:43 UTC 2021


Replace remaining uses of VIR_FREE with g_clear_pointer.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 tools/vsh.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index f4b555fb8b..1f384d4ea6 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -2253,10 +2253,7 @@ vshCloseLogFile(vshControl *ctl)
                  g_strerror(errno));
     }
 
-    if (ctl->logfile) {
-        VIR_FREE(ctl->logfile);
-        ctl->logfile = NULL;
-    }
+    g_clear_pointer(&ctl->logfile, g_free);
 }
 
 #ifndef WIN32
@@ -2852,8 +2849,8 @@ vshReadlineDeinit(vshControl *ctl)
         }
     }
 
-    VIR_FREE(ctl->historydir);
-    VIR_FREE(ctl->historyfile);
+    g_clear_pointer(&ctl->historydir, g_free);
+    g_clear_pointer(&ctl->historyfile, g_free);
 }
 
 char *
-- 
2.31.1




More information about the libvir-list mailing list