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.slep...@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetso...@altlinux.org>
---
 src/qemu/qemu_snapshot.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 80cd54bf33..d277f76b4b 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -3465,7 +3465,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) {
@@ -3475,7 +3475,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:
@@ -3485,7 +3485,7 @@ qemuSnapshotDeleteBlockJobIsActive(qemuBlockjobState 
state)
         break;
     }
 
-    return 0;
+    return false;
 }
 
 
@@ -3513,18 +3513,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;
 }
 
-- 
2.42.4

Reply via email to