]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing()
authorAlexander Kuznetsov <kuznetsovam@altlinux.org>
Wed, 22 Jan 2025 14:14:31 +0000 (17:14 +0300)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 6 Mar 2025 14:04:06 +0000 (15:04 +0100)
qemuSnapshotDeleteBlockJobFinishing() returns only 0 and 1. Convert it
to bool and remove the dead code handling -1 return in the caller.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Reported-by: Reported-by: Andrey Slepykh <a.slepykh@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_snapshot.c

index 891e67e98b0f6c6b61ad23b8a0e550698931acd2..0d940d3d3809ea823afbf432171fd3e65e5b2615 100644 (file)
@@ -3492,7 +3492,7 @@ qemuSnapshotDeleteBlockJobIsRunning(qemuBlockjobState state)
 
 /* When finishing or aborting qemu blockjob we only need to know if the
  * job is still active or not. */
-static int
+static bool
 qemuSnapshotDeleteBlockJobIsActive(qemuBlockjobState state)
 {
     switch (state) {
@@ -3502,7 +3502,7 @@ qemuSnapshotDeleteBlockJobIsActive(qemuBlockjobState state)
     case QEMU_BLOCKJOB_STATE_ABORTING:
     case QEMU_BLOCKJOB_STATE_PENDING:
     case QEMU_BLOCKJOB_STATE_PIVOTING:
-        return 1;
+        return true;
 
     case QEMU_BLOCKJOB_STATE_COMPLETED:
     case QEMU_BLOCKJOB_STATE_FAILED:
@@ -3512,7 +3512,7 @@ qemuSnapshotDeleteBlockJobIsActive(qemuBlockjobState state)
         break;
     }
 
-    return 0;
+    return false;
 }
 
 
@@ -3540,18 +3540,14 @@ static int
 qemuSnapshotDeleteBlockJobFinishing(virDomainObj *vm,
                                     qemuBlockJobData *job)
 {
-    int rc;
     qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT);
 
-    while ((rc = qemuSnapshotDeleteBlockJobIsActive(job->state)) > 0) {
+    while (qemuSnapshotDeleteBlockJobIsActive(job->state)) {
         if (qemuDomainObjWait(vm) < 0)
             return -1;
         qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT);
     }
 
-    if (rc < 0)
-        return -1;
-
     return 0;
 }