[PATCH 07/23] virshEventPrint: Use automatic memory clearing

Peter Krempa pkrempa at redhat.com
Wed Mar 2 13:55:06 UTC 2022


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tools/virsh-domain.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 25097627ac..33984618eb 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -13166,13 +13166,13 @@ static void
 virshEventPrint(virshDomEventData *data,
                 virBuffer *buf)
 {
-    char *msg;
+    g_autofree char *msg = NULL;

     if (!(msg = virBufferContentAndReset(buf)))
         return;

     if (!data->loop && *data->count)
-        goto cleanup;
+        return;

     if (data->timestamp) {
         char timestamp[VIR_TIME_STRING_BUFLEN];
@@ -13188,9 +13188,6 @@ virshEventPrint(virshDomEventData *data,
     (*data->count)++;
     if (!data->loop)
         vshEventDone(data->ctl);
-
- cleanup:
-    VIR_FREE(msg);
 }

 static void
-- 
2.35.1




More information about the libvir-list mailing list