[libvirt PATCH 5/5] util: use g_auto in virNodeSuspendHelper

Ján Tomko jtomko at redhat.com
Mon Dec 13 18:58:50 UTC 2021


Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/util/virnodesuspend.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index c92232dfe9..e1167605ca 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -102,7 +102,7 @@ static int virNodeSuspendSetNodeWakeup(unsigned long long alarmTime)
  */
 static void virNodeSuspendHelper(void *cmdString)
 {
-    virCommand *suspendCmd = virCommandNew((const char *)cmdString);
+    g_autoptr(virCommand) suspendCmd = virCommandNew((const char *)cmdString);
 
     /*
      * Delay for sometime so that the function virNodeSuspend()
@@ -112,8 +112,6 @@ static void virNodeSuspendHelper(void *cmdString)
     if (virCommandRun(suspendCmd, NULL) < 0)
         VIR_WARN("Failed to suspend the host");
 
-    virCommandFree(suspendCmd);
-
     /*
      * Now that we have resumed from suspend or the suspend failed,
      * reset 'aboutToSuspend' flag.
-- 
2.31.1




More information about the libvir-list mailing list