From nobody Sun Dec 22 07:49:51 2024 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 1734342299742334.04353841294085; Mon, 16 Dec 2024 01:44:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C91C3155B; Mon, 16 Dec 2024 04:44:58 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AFC8814CF; Mon, 16 Dec 2024 04:43:59 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6AA40B33; Mon, 16 Dec 2024 04:43:53 -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 CF4EBB0E for ; Mon, 16 Dec 2024 04:43:52 -0500 (EST) Received: from kuznetsovam-nb.office.basealt.ru (unknown [193.43.10.250]) by air.basealt.ru (Postfix) with ESMTPSA id B47A02339E; Mon, 16 Dec 2024 12:43:51 +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=-0.7 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 From: Alexander Kuznetsov To: jdenemar@redhat.com, devel@lists.libvirt.org Subject: [PATCH v3 2/4] util: Change return type of virSCSIDeviceSetUsedBy to void Date: Mon, 16 Dec 2024 12:41:06 +0300 Message-ID: <20241216094308.17957-3-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.2 In-Reply-To: <20241216094308.17957-1-kuznetsovam@altlinux.org> References: <20241128133105.31975-1-kuznetsovam@altlinux.org> <20241216094308.17957-1-kuznetsovam@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZPYNLJRJ4KLP3CYC45P75FUTW7V455MS X-Message-ID-Hash: ZPYNLJRJ4KLP3CYC45P75FUTW7V455MS 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, pkrempa@redhat.com 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: 1734342301155116600 Content-Type: text/plain; charset="utf-8" This function return value is invariant since 18f3771, so change its type and remove all dependent checks. Found by Linux Verification Center (linuxtesting.org) with Svace. Reported-by: Pavel Nekrasov Signed-off-by: Alexander Kuznetsov --- src/hypervisor/virhostdev.c | 13 +++++-------- src/util/virscsi.c | 4 +--- src/util/virscsi.h | 6 +++--- tests/virscsitest.c | 6 ++---- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index f8b5ab86e1..84c036e075 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -1212,11 +1212,10 @@ virHostdevUpdateActiveSCSIHostDevices(virHostdevMan= ager *mgr, return -1; =20 if ((tmp =3D virSCSIDeviceListFind(mgr->activeSCSIHostdevs, scsi))) { - if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0) - return -1; + virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name); } else { - if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0 || - virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) + virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name); + if (virSCSIDeviceListAdd(mgr->activeSCSIHostdevs, scsi) < 0) return -1; scsi =3D NULL; } @@ -1597,11 +1596,9 @@ virHostdevPrepareSCSIDevices(virHostdevManager *mgr, goto error; } =20 - if (virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name) < 0) - goto error; + virSCSIDeviceSetUsedBy(tmp, drv_name, dom_name); } else { - if (virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name) < 0) - goto error; + virSCSIDeviceSetUsedBy(scsi, drv_name, dom_name); =20 VIR_DEBUG("Adding %s to activeSCSIHostdevs", virSCSIDeviceGetN= ame(scsi)); =20 diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 3d2c77e3b8..6899958e21 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -243,7 +243,7 @@ virSCSIDeviceFree(virSCSIDevice *dev) g_free(dev); } =20 -int +void virSCSIDeviceSetUsedBy(virSCSIDevice *dev, const char *drvname, const char *domname) @@ -255,8 +255,6 @@ virSCSIDeviceSetUsedBy(virSCSIDevice *dev, copy->domname =3D g_strdup(domname); =20 VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy); - - return 0; } =20 bool diff --git a/src/util/virscsi.h b/src/util/virscsi.h index ec34303bdc..8d7c00160b 100644 --- a/src/util/virscsi.h +++ b/src/util/virscsi.h @@ -50,9 +50,9 @@ virSCSIDevice *virSCSIDeviceNew(const char *sysfs_prefix, bool shareable); =20 void virSCSIDeviceFree(virSCSIDevice *dev); -int virSCSIDeviceSetUsedBy(virSCSIDevice *dev, - const char *drvname, - const char *domname); +void virSCSIDeviceSetUsedBy(virSCSIDevice *dev, + const char *drvname, + const char *domname); bool virSCSIDeviceIsAvailable(virSCSIDevice *dev); const char *virSCSIDeviceGetName(virSCSIDevice *dev); const char *virSCSIDeviceGetPath(virSCSIDevice *dev); diff --git a/tests/virscsitest.c b/tests/virscsitest.c index c96699e157..2c3b599c7a 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -87,14 +87,12 @@ test2(const void *data G_GNUC_UNUSED) if (!virSCSIDeviceIsAvailable(dev)) goto cleanup; =20 - if (virSCSIDeviceSetUsedBy(dev, "QEMU", "fc18") < 0) - goto cleanup; + virSCSIDeviceSetUsedBy(dev, "QEMU", "fc18"); =20 if (virSCSIDeviceIsAvailable(dev)) goto cleanup; =20 - if (virSCSIDeviceSetUsedBy(dev, "QEMU", "fc20") < 0) - goto cleanup; + virSCSIDeviceSetUsedBy(dev, "QEMU", "fc20"); =20 if (virSCSIDeviceIsAvailable(dev)) goto cleanup; --=20 2.42.2