From nobody Sun Dec 22 08:24:18 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 1732807791160933.886040774931; Thu, 28 Nov 2024 07:29:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A39D175E; Thu, 28 Nov 2024 10:29:50 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6F4701D4D; Thu, 28 Nov 2024 10:27:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 34E741C1C; Thu, 28 Nov 2024 10:23:03 -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 95F8117D8 for ; Thu, 28 Nov 2024 10:23:02 -0500 (EST) Received: from kuznetsovam-nb.office.basealt.ru (unknown [193.43.10.250]) by air.basealt.ru (Postfix) with ESMTPSA id 786AF23418; Thu, 28 Nov 2024 18:23:01 +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 From: Alexander Kuznetsov To: devel@lists.libvirt.org Subject: [PATCH v2 6/6] util: virsysinfo: Change return type of functions that never fail to void Date: Thu, 28 Nov 2024 18:21:22 +0300 Message-ID: <20241128152222.50660-7-kuznetsovam@altlinux.org> X-Mailer: git-send-email 2.42.2 In-Reply-To: <20241128152222.50660-1-kuznetsovam@altlinux.org> References: <20241128152222.50660-1-kuznetsovam@altlinux.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MailFrom: kuznetsovam@altlinux.org X-Mailman-Rule-Hits: nonmember-moderation 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 Message-ID-Hash: U4ZMWGINTIP3C76HGUOM7YOIF5YGMSQU X-Message-ID-Hash: U4ZMWGINTIP3C76HGUOM7YOIF5YGMSQU X-Mailman-Approved-At: Thu, 28 Nov 2024 15:27:19 -0500 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: 1732807792028019100 Content-Type: text/plain; charset="utf-8" These functions return value is invariant since VIR_EXPAND_N check removal in 7d2fd6e, 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 Reviewed-by: Jiri Denemark --- src/util/virsysinfo.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index dbcbca62ed..d9b2b5e89e 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -263,7 +263,7 @@ virSysinfoParsePPCSystem(const char *base, virSysinfoSy= stemDef **sysdef) return ret; } =20 -static int +static void virSysinfoParsePPCProcessor(const char *base, virSysinfoDef *ret) { const char *cur; @@ -303,8 +303,6 @@ virSysinfoParsePPCProcessor(const char *base, virSysinf= oDef *ret) } =20 } - - return 0; } =20 /* virSysinfoRead for PowerPC @@ -325,8 +323,7 @@ virSysinfoReadPPC(void) =20 ret->nprocessor =3D 0; ret->processor =3D NULL; - if (virSysinfoParsePPCProcessor(outbuf, ret) < 0) - return NULL; + virSysinfoParsePPCProcessor(outbuf, ret); =20 if (virSysinfoParsePPCSystem(outbuf, &ret->system) < 0) return NULL; @@ -383,7 +380,7 @@ virSysinfoParseARMSystem(const char *base, virSysinfoSy= stemDef **sysdef) return ret; } =20 -static int +static void virSysinfoParseARMProcessor(const char *base, virSysinfoDef *ret) { const char *cur; @@ -393,7 +390,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinf= oDef *ret) =20 if (!(tmp_base =3D strstr(base, "model name")) && !(tmp_base =3D strstr(base, "Processor"))) - return 0; + return; =20 eol =3D strchr(tmp_base, '\n'); cur =3D strchr(tmp_base, ':') + 1; @@ -420,7 +417,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinf= oDef *ret) } =20 VIR_FREE(processor_type); - return 0; + return; } =20 /* virSysinfoRead for ARMv7 @@ -451,8 +448,7 @@ virSysinfoReadARM(void) =20 ret->nprocessor =3D 0; ret->processor =3D NULL; - if (virSysinfoParseARMProcessor(outbuf, ret) < 0) - return NULL; + virSysinfoParseARMProcessor(outbuf, ret); =20 if (virSysinfoParseARMSystem(outbuf, &ret->system) < 0) return NULL; @@ -753,7 +749,7 @@ virSysinfoParseX86System(const char *base, virSysinfoSy= stemDef **sysdef) return ret; } =20 -static int +static void virSysinfoParseX86BaseBoard(const char *base, virSysinfoBaseBoardDef **baseBoard, size_t *nbaseBoard) @@ -827,7 +823,6 @@ virSysinfoParseX86BaseBoard(const char *base, =20 *nbaseBoard =3D nboards; *baseBoard =3D g_steal_pointer(&boards); - return 0; } =20 =20 @@ -1006,7 +1001,7 @@ virSysinfoParseOEMStrings(const char *base, } =20 =20 -static int +static void virSysinfoParseX86Processor(const char *base, virSysinfoDef *ret) { const char *cur, *tmp_base; @@ -1102,11 +1097,9 @@ virSysinfoParseX86Processor(const char *base, virSys= infoDef *ret) =20 base +=3D strlen("Processor Information"); } - - return 0; } =20 -static int +static void virSysinfoParseX86Memory(const char *base, virSysinfoDef *ret) { const char *cur, *tmp_base; @@ -1197,8 +1190,6 @@ virSysinfoParseX86Memory(const char *base, virSysinfo= Def *ret) next: base +=3D strlen("Memory Device"); } - - return 0; } =20 virSysinfoDef * @@ -1223,8 +1214,7 @@ virSysinfoReadDMI(void) if (virSysinfoParseX86System(outbuf, &ret->system) < 0) return NULL; =20 - if (virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBo= ard) < 0) - return NULL; + virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBoard); =20 if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0) return NULL; @@ -1234,13 +1224,11 @@ virSysinfoReadDMI(void) =20 ret->nprocessor =3D 0; ret->processor =3D NULL; - if (virSysinfoParseX86Processor(outbuf, ret) < 0) - return NULL; + virSysinfoParseX86Processor(outbuf, ret); =20 ret->nmemory =3D 0; ret->memory =3D NULL; - if (virSysinfoParseX86Memory(outbuf, ret) < 0) - return NULL; + virSysinfoParseX86Memory(outbuf, ret); =20 return g_steal_pointer(&ret); } --=20 2.42.2