[PATCH] qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing()

Alexander Kuznetsov posted 1 patch 7 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20250122141437.31699-1-kuznetsovam@altlinux.org
src/qemu/qemu_snapshot.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
[PATCH] qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing()
Posted by Alexander Kuznetsov 7 months, 2 weeks ago
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>
---
 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
Re: [PATCH] qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing()
Posted by Martin Kletzander 6 months ago
On Wed, Jan 22, 2025 at 05:14:31PM +0300, Alexander Kuznetsov wrote:
>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>

Unfortunately I noticed the double "Reported-by" only now.

>Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

and pushed.
Re: [PATCH] qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing()
Posted by Alexander Kuznetsov 7 months ago
Kindly reminding about this small cosmetic fix