[PATCH] qemu: snapshot: Remove dead code in 'qemuSnapshotDeleteBlockJobRunning'

Peter Krempa posted 1 patch 2 weeks, 5 days ago
src/qemu/qemu_snapshot.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
[PATCH] qemu: snapshot: Remove dead code in 'qemuSnapshotDeleteBlockJobRunning'
Posted by Peter Krempa 2 weeks, 5 days ago
'qemuSnapshotDeleteBlockJobIsRunning' returns only 0 and 1. Convert it
to bool and remove the dead code handling -1 return in the caller.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/682
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 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 77ff842fab..1187ebf276 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -3303,7 +3303,7 @@ qemuSnapshotDeleteUpdateDisks(void *payload,
 /* Deleting external snapshot is started by running qemu block-commit job.
  * We need to wait for all block-commit jobs to be 'ready' or 'pending' to
  * continue with external snapshot deletion. */
-static int
+static bool
 qemuSnapshotDeleteBlockJobIsRunning(qemuBlockjobState state)
 {
     switch (state) {
@@ -3311,7 +3311,7 @@ qemuSnapshotDeleteBlockJobIsRunning(qemuBlockjobState state)
     case QEMU_BLOCKJOB_STATE_RUNNING:
     case QEMU_BLOCKJOB_STATE_ABORTING:
     case QEMU_BLOCKJOB_STATE_PIVOTING:
-        return 1;
+        return true;

     case QEMU_BLOCKJOB_STATE_COMPLETED:
     case QEMU_BLOCKJOB_STATE_FAILED:
@@ -3323,7 +3323,7 @@ qemuSnapshotDeleteBlockJobIsRunning(qemuBlockjobState state)
         break;
     }

-    return 0;
+    return false;
 }


@@ -3359,18 +3359,14 @@ static int
 qemuSnapshotDeleteBlockJobRunning(virDomainObj *vm,
                                   qemuBlockJobData *job)
 {
-    int rc;
     qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT);

-    while ((rc = qemuSnapshotDeleteBlockJobIsRunning(job->state)) > 0) {
+    while (qemuSnapshotDeleteBlockJobIsRunning(job->state)) {
         if (qemuDomainObjWait(vm) < 0)
             return -1;
         qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT);
     }

-    if (rc < 0)
-        return -1;
-
     return 0;
 }

-- 
2.46.2
Re: [PATCH] qemu: snapshot: Remove dead code in 'qemuSnapshotDeleteBlockJobRunning'
Posted by Pavel Hrdina 2 weeks, 5 days ago
On Mon, Oct 14, 2024 at 08:18:15AM +0200, Peter Krempa wrote:
> 'qemuSnapshotDeleteBlockJobIsRunning' returns only 0 and 1. Convert it
> to bool and remove the dead code handling -1 return in the caller.
> 
> Closes: https://gitlab.com/libvirt/libvirt/-/issues/682
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_snapshot.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>