From nobody Sat Feb 7 05:13:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16336721062584.980533566926852; Thu, 7 Oct 2021 22:48:26 -0700 (PDT) Received: from localhost ([::1]:59128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYik4-0001si-ST for importer@patchew.org; Fri, 08 Oct 2021 01:48:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYiiK-0000Yd-Gl for qemu-devel@nongnu.org; Fri, 08 Oct 2021 01:46:36 -0400 Received: from mail.csgraf.de ([85.25.223.15]:34842 helo=zulu616.server4you.de) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYiiE-0004QB-I9 for qemu-devel@nongnu.org; Fri, 08 Oct 2021 01:46:36 -0400 Received: from localhost.localdomain (unknown [46.183.103.8]) by csgraf.de (Postfix) with ESMTPSA id C918760801CD; Fri, 8 Oct 2021 07:46:20 +0200 (CEST) From: Alexander Graf To: QEMU Developers Subject: [PATCH] hvf: Determine slot count from struct layout Date: Fri, 8 Oct 2021 07:46:16 +0200 Message-Id: <20211008054616.43828-1-agraf@csgraf.de> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=85.25.223.15; envelope-from=agraf@csgraf.de; helo=zulu616.server4you.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , Cameron Esfahani Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633672109203100001 Content-Type: text/plain; charset="utf-8" We can handle up to a static amount of memory slots, capped by the size of an internal array. Let's make sure that array size is the only source of truth for the number of elements in that array. Signed-off-by: Alexander Graf Reviewed-by: Richard Henderson --- accel/hvf/hvf-accel-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 6cbd2c3f97..2b2c411076 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -321,7 +321,7 @@ static int hvf_accel_init(MachineState *ms) =20 s =3D g_new0(HVFState, 1); =20 - s->num_slots =3D 32; + s->num_slots =3D ARRAY_SIZE(s->slots); for (x =3D 0; x < s->num_slots; ++x) { s->slots[x].size =3D 0; s->slots[x].slot_id =3D x; --=20 2.30.1 (Apple Git-130)