]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: refactor virNodeSuspendSetNodeWakeup
authorJán Tomko <jtomko@redhat.com>
Mon, 13 Dec 2021 18:51:42 +0000 (19:51 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 14 Dec 2021 15:41:36 +0000 (16:41 +0100)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnodesuspend.c

index 451d798363222931e3e1ed3a85a703d9fbd1ff6f..c92232dfe96e068522c7c2b376930c4cb86dd92d 100644 (file)
@@ -73,8 +73,7 @@ static void virNodeSuspendUnlock(void)
  */
 static int virNodeSuspendSetNodeWakeup(unsigned long long alarmTime)
 {
-    virCommand *setAlarmCmd;
-    int ret = -1;
+    g_autoptr(virCommand) setAlarmCmd = NULL;
 
     if (alarmTime < MIN_TIME_REQ_FOR_SUSPEND) {
         virReportError(VIR_ERR_INVALID_ARG,
@@ -86,14 +85,7 @@ static int virNodeSuspendSetNodeWakeup(unsigned long long alarmTime)
     setAlarmCmd = virCommandNewArgList("rtcwake", "-m", "no", "-s", NULL);
     virCommandAddArgFormat(setAlarmCmd, "%lld", alarmTime);
 
-    if (virCommandRun(setAlarmCmd, NULL) < 0)
-        goto cleanup;
-
-    ret = 0;
-
- cleanup:
-    virCommandFree(setAlarmCmd);
-    return ret;
+    return virCommandRun(setAlarmCmd, NULL);
 }
 
 /**