From nobody Fri Dec 19 14:30:40 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1589204928; cv=none; d=zohomail.com; s=zohoarc; b=dvGq2l182y4zXA3i7q5R5XBH3Ef0pRMq8s+ULqKDEksMcrDLht/SscoDslKYQT1ZvkWQGbCnGi93E/chU2am6fAph6ShkuaYDB1yklXbp8/v1tYW+k9thicoWo4TOsyYaEmWp81WhyJu4usQMSSvDbjhZuTAM1MVh7460IypBOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589204928; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XSEEKypaUPHa3YKv/s4gpdUF8gfQ0Q/8VrxqSnRvXag=; b=TFmGihNf5VhCnz7Di91EfsNdo6qyvqU2o07f+45nfq9REzdjH2Gr84qKsCxN4CZChPNGAt6iLClmDLibIk6udScv0O5/BmpGKiHP/XrzvsGvUsBFO2A4trzDR/6N4FR3mst6cT+KktvsmD3wwiV63EsJEbaitmW8yV+X+8lajRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589204928813174.21660346506474; Mon, 11 May 2020 06:48:48 -0700 (PDT) Received: from localhost ([::1]:42636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jY8nX-0002hA-8V for importer@patchew.org; Mon, 11 May 2020 09:48:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jY8Zz-0002cu-6T for qemu-devel@nongnu.org; Mon, 11 May 2020 09:34:47 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:39230) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jY8Zy-0007Ey-AC for qemu-devel@nongnu.org; Mon, 11 May 2020 09:34:46 -0400 Received: by mail-wm1-x32c.google.com with SMTP id y24so19314645wma.4 for ; Mon, 11 May 2020 06:34:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m3sm2154818wrn.96.2020.05.11.06.34.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 06:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XSEEKypaUPHa3YKv/s4gpdUF8gfQ0Q/8VrxqSnRvXag=; b=MB36tHAjfWLuNmNRjVSRDDD7o99WUwlcnEL3g+Wik207G+qWGL9r00+ZECSWk4Onqp bRLCOZuRKyh8BvE3+5c845AysM9k7GhGsqzssIcJ6ITyizGFxEXZI01TPkDtJPdG3vkD VdbquIgJuZxDgtmCqt39VnA9mVCZKRYfpSGdsoUCr29nqz03zOjWsy3MrbEBXZGBaVL2 HnS9G4yuvjVboyP26/zXQd8nAzAVgXip9KR3cgpVpDWm1Y9JElwNAwAVAPMpB4SJGKOX j+IGTUcn1szidkimmPrlghNZhunJN9PFUlawj2AhCKozy8d4i0b8udWreIytIAjiMrtZ 0ffA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XSEEKypaUPHa3YKv/s4gpdUF8gfQ0Q/8VrxqSnRvXag=; b=PE9MsrAOPxxE9VF6LInQzJlMtYMiiIflxgeKzxAmRI83dKFB6BOiNj/vkU8l/T6Mfp vtqXk1EhPMuFpNNLvcJjSrfOL+SCkjyaNayc5lzGpcloPl1unQl5XWgq+lYUdNNmvKT2 8xgSdFmW+XMhZd19jP8R1yHsdbMV8FVEI4dV4FLmqoSp04nYpyqRJEUqIHXzDVsPKGXh ZvrwqJ3hf3issb/+2FFIQn3t3bN66ZC7COB/4UzQuCRVzU/KBR2GjZaCS/cJ7M7huu+O Gnh535VN3xt4Sjk29hasnGyNsjTlcDsASGTKYVYH5xtW0EFWzmoDuRXHUP+drdzV6Hmv 6jgQ== X-Gm-Message-State: AGi0PuZ59YpdVwvwBXJpJj/wptxNIqwZCXa/DjjnOyWyVKqv2DJpyDfE l9FfSk5Y7MpIGUkS8+dVhbIMAQWpRZJZXw== X-Google-Smtp-Source: APiQypKh7twA3QkiyzkT65EFMzdNXRja7A+gdF2UwThzHdT52JEtOeMCuZtgfmq91Fy75cWh6ZJJaw== X-Received: by 2002:a1c:bc08:: with SMTP id m8mr31295488wmf.119.1589204084630; Mon, 11 May 2020 06:34:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/34] target/arm/cpu: Use ARRAY_SIZE() to iterate over ARMCPUInfo[] Date: Mon, 11 May 2020 14:34:00 +0100 Message-Id: <20200511133405.5275-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200511133405.5275-1-peter.maydell@linaro.org> References: <20200511133405.5275-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Use ARRAY_SIZE() to iterate over ARMCPUInfo[]. Since on the aarch64-linux-user build, arm_cpus[] is empty, add the cpu_count variable and only iterate when it is non-zero. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200504172448.9402-4-philmd@redhat.com Signed-off-by: Peter Maydell --- target/arm/cpu.c | 16 +++++++++------- target/arm/cpu64.c | 8 +++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 13959cb6435..b4d73dd47c1 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2739,7 +2739,6 @@ static const ARMCPUInfo arm_cpus[] =3D { { .name =3D "any", .initfn =3D arm_max_initfn }, #endif #endif - { .name =3D NULL } }; =20 static Property arm_cpu_properties[] =3D { @@ -2887,19 +2886,22 @@ static const TypeInfo idau_interface_type_info =3D { =20 static void arm_cpu_register_types(void) { - const ARMCPUInfo *info =3D arm_cpus; + const size_t cpu_count =3D ARRAY_SIZE(arm_cpus); =20 type_register_static(&arm_cpu_type_info); type_register_static(&idau_interface_type_info); =20 - while (info->name) { - arm_cpu_register(info); - info++; - } - #ifdef CONFIG_KVM type_register_static(&host_arm_cpu_type_info); #endif + + if (cpu_count) { + size_t i; + + for (i =3D 0; i < cpu_count; ++i) { + arm_cpu_register(&arm_cpus[i]); + } + } } =20 type_init(arm_cpu_register_types) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index cbaa5ed2287..f5c49ee32d0 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -734,7 +734,6 @@ static const ARMCPUInfo aarch64_cpus[] =3D { { .name =3D "cortex-a53", .initfn =3D aarch64_a53_initfn }, { .name =3D "cortex-a72", .initfn =3D aarch64_a72_initfn }, { .name =3D "max", .initfn =3D aarch64_max_initfn }, - { .name =3D NULL } }; =20 static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp) @@ -840,13 +839,12 @@ static const TypeInfo aarch64_cpu_type_info =3D { =20 static void aarch64_cpu_register_types(void) { - const ARMCPUInfo *info =3D aarch64_cpus; + size_t i; =20 type_register_static(&aarch64_cpu_type_info); =20 - while (info->name) { - aarch64_cpu_register(info); - info++; + for (i =3D 0; i < ARRAY_SIZE(aarch64_cpus); ++i) { + aarch64_cpu_register(&aarch64_cpus[i]); } } =20 --=20 2.20.1