From nobody Wed Dec 17 08:55:58 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; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1744032334; cv=none; d=zohomail.com; s=zohoarc; b=lxoZYa4Xn59DCXFOu1M4YwrNxwfxQPqyvI8iedPt4GEO0YZ6gsIv8UtE7hBtCGkcQkRsIQlt1qjkUMc0o7WRh/o3QcKCeiw2EUCYI1Do8dAIxI5C5MKtcSyzqEWQQ/s1vmyvfEqaqqdkXvVs5MZ8zMMYJoT5QRPtanJR52zkvDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744032334; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=uxC7l5vRorzHZCh23tmlMl/nCO6vSd8dVLhysojYau4=; b=bdo/MRazNaNSWJpnXOnQv2XWMj6lzSD/HJ5IwgT4KQSnr2tWLlHb9TtUoSQCGKBG+OWDCr9hoUzPn9MU2qzlmFLQadTE0KZR0HLHPvpwu9GKhYPkygdVo6xB3Xl6LQbLN7wGeWrm+6vvBGFhY5OKk563wHUWtkRKnlrMXxE0oL8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1744032334372434.25555811730453; Mon, 7 Apr 2025 06:25:34 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 51FC616F4; Mon, 7 Apr 2025 09:25:33 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 81CBF16DE; Mon, 7 Apr 2025 09:24:34 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1D95B11C8; Mon, 7 Apr 2025 09:24:28 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 7675D11C8 for ; Mon, 7 Apr 2025 09:24:27 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-MhrX_8rePfqicn2vA3Acng-1; Mon, 07 Apr 2025 09:24:25 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DC32418001FC for ; Mon, 7 Apr 2025 13:24:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.8]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB08D1955BC0; Mon, 7 Apr 2025 13:24:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744032267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pnrqg3wuexVPinJKYyTl0enRi17kdc0l3YJbeR8sAp4=; b=PMXTh3A/0oa5j18OlcwFl4huWUsI9L/Zx+ThrXDcucmP7VRTls196jEc0c2S359fz8vi3v mabsR7Q5uap9w8Wk/ZlWJNfut12Ca+jbbMPLfIbTyqAPahmfyPQcehgNgRCoZcZL9hRd3n EQEFkj7qBR7pw7BAMP6D25vAbypbjmM= X-MC-Unique: MhrX_8rePfqicn2vA3Acng-1 X-Mimecast-MFC-AGG-ID: MhrX_8rePfqicn2vA3Acng_1744032264 To: devel@lists.libvirt.org Subject: [PATCH 2/5] virHostCPUGetInfoPopulateLinux: Remove 'cleanup' Date: Mon, 7 Apr 2025 15:24:14 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: TE3-1F_1ZhmBui83rrppJxAkq2S1lw_0xZcesAJLzU8_1744032264 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HCVMTT7L7FOFTI6Q6DC65D7HXELI5MCI X-Message-ID-Hash: HCVMTT7L7FOFTI6Q6DC65D7HXELI5MCI X-MailFrom: pkrempa@redhat.com 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: Peter Krempa 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: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1744032337598019100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa As the cleanup section is empty; the code can now return directly on errors. Signed-off-by: Peter Krempa --- src/util/virhostcpu.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index c4138076d9..2c4c75731c 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -643,7 +643,6 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, int nodecpus, nodecores, nodesockets, nodethreads, offline =3D 0; int threads_per_subcore =3D 0; unsigned int node; - int ret =3D -1; g_autofree char *sysfs_nodedir =3D NULL; g_autofree char *sysfs_cpudir_fallback =3D NULL; int direrr; @@ -659,12 +658,11 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, /* Get information about what CPUs are present in the host and what * CPUs are online, so that we don't have to so for each node */ - present_cpus_map =3D virHostCPUGetPresentBitmap(); - if (!present_cpus_map) - goto cleanup; - online_cpus_map =3D virHostCPUGetOnlineBitmap(); - if (!online_cpus_map) - goto cleanup; + if (!(present_cpus_map =3D virHostCPUGetPresentBitmap())) + return -1; + + if (!(online_cpus_map =3D virHostCPUGetOnlineBitmap())) + return -1; /* OK, we've parsed clock speed out of /proc/cpuinfo. Get the * core, node, socket, thread and topology information from /sys @@ -699,7 +697,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, * On hosts other than POWER this will be 0, in which case a simpler * thread-counting logic will be used */ if ((threads_per_subcore =3D virHostCPUGetThreadsPerSubcore(arch)) < 0) - goto cleanup; + return -1; /* If the subcore configuration is not valid, just pretend subcores * are not in use and count threads one by one */ @@ -723,7 +721,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, threads_per_subcore, &nodesockets, &nodecores, &nodethreads, &offline)) < 0) - goto cleanup; + return -1; *cpus +=3D nodecpus; @@ -738,7 +736,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, } if (direrr < 0) - goto cleanup; + return -1; if (*cpus && *nodes) goto done; @@ -752,7 +750,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, threads_per_subcore, &nodesockets, &nodecores, &nodethreads, &offline)) < 0) - goto cleanup; + return -1; *nodes =3D 1; *cpus =3D nodecpus; @@ -764,17 +762,17 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, /* There should always be at least one cpu, socket, node, and thread. = */ if (*cpus =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no CPUs found")); - goto cleanup; + return -1; } if (*sockets =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no sockets found")= ); - goto cleanup; + return -1; } if (*threads =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no threads found")= ); - goto cleanup; + return -1; } /* Now check if the topology makes sense. There are machines that don't @@ -794,10 +792,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, *threads =3D 1; } - ret =3D 0; - - cleanup: - return ret; + return 0; } # define TICK_TO_NSEC (1000ull * 1000ull * 1000ull / sysconf(_SC_CLK_TCK)) --=20 2.49.0