From: Alexander Kuznetsov Date: Wed, 22 Jan 2025 14:14:31 +0000 (+0300) Subject: qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing() X-Git-Tag: v11.2.0-rc1~260 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8acc0b76c64861a3f65b9bd430881250cccdc5f9;p=thirdparty%2Flibvirt.git qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing() 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 Signed-off-by: Alexander Kuznetsov Reviewed-by: Martin Kletzander --- diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 891e67e98b..0d940d3d38 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -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; }