From nobody Tue Sep 9 19:05:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737555927349501.4862335180459; Wed, 22 Jan 2025 06:25:27 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 95F14140D; Wed, 22 Jan 2025 09:25:26 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2C42813E0; Wed, 22 Jan 2025 09:25:08 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4C30713E0; Wed, 22 Jan 2025 09:25:04 -0500 (EST) Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 471DC13C0 for ; Wed, 22 Jan 2025 09:25:03 -0500 (EST) Received: from kuznetsovam-nb.office.basealt.ru (unknown [193.43.10.250]) (Authenticated sender: kuznetsovam) by air.basealt.ru (Postfix) with ESMTPSA id 329D723389; Wed, 22 Jan 2025 17:15:20 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 581 seconds by postgrey-1.37 at lists.libvirt.org; Wed, 22 Jan 2025 09:25:03 EST From: Alexander Kuznetsov To: devel@lists.libvirt.org Subject: [PATCH] qemu: snapshot: Remove dead code in qemuSnapshotDeleteBlockJobFinishing() Date: Wed, 22 Jan 2025 17:14:31 +0300 Message-ID: <20250122141437.31699-1-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5LQTQ2RJFATFQ34MTDUNELPFQMZ22TBE X-Message-ID-Hash: 5LQTQ2RJFATFQ34MTDUNELPFQMZ22TBE X-MailFrom: kuznetsovam@altlinux.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: nickel@altlinux.org, egori@altlinux.org X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZM-MESSAGEID: 1737555933235019000 Content-Type: text/plain; charset="utf-8" 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 --- 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) =20 /* 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; =20 case QEMU_BLOCKJOB_STATE_COMPLETED: case QEMU_BLOCKJOB_STATE_FAILED: @@ -3485,7 +3485,7 @@ qemuSnapshotDeleteBlockJobIsActive(qemuBlockjobState = state) break; } =20 - return 0; + return false; } =20 =20 @@ -3513,18 +3513,14 @@ static int qemuSnapshotDeleteBlockJobFinishing(virDomainObj *vm, qemuBlockJobData *job) { - int rc; qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); =20 - while ((rc =3D qemuSnapshotDeleteBlockJobIsActive(job->state)) > 0) { + while (qemuSnapshotDeleteBlockJobIsActive(job->state)) { if (qemuDomainObjWait(vm) < 0) return -1; qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); } =20 - if (rc < 0) - return -1; - return 0; } =20 --=20 2.42.4