From nobody Sun May 19 04:35:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591633985; cv=none; d=zohomail.com; s=zohoarc; b=m+bjKQGvyn6jfqtIFHBlWZ7qUPiyTYNdjWHpSVEKg/8sydBApjIbqU6rCzasS3fFJsnfoghLuGopOMbJJZ1Uqz6k2mFqA0Cpmu6qJfdQhVLdcJpUwXwHmwx5iR1VrEMWD6NMV7qZQd1ITCfcQmCyw+HX1JijyXCx8OgdODpMFOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591633985; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IQ2Zwmt+Uey5o0Uah3Zvdno8y42e5J5YjRZjcD6UUkc=; b=IYkRHib4DSJ8tFhN6Y4q51+IjlIxJ8E3OoVjStUx/M8d/+XGWVAr3fge5z3T4JU3zocEca4HCyU5IEeopkYNsccAnalSn1L4Dp7xHVU5WFQe775n74hFTdq30+ZWS184BaT8JQ2xObI1NWI7OLj6zeoR8KEyneDOgxPAYxKL3nE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1591633985923606.0836339587001; Mon, 8 Jun 2020 09:33:05 -0700 (PDT) Received: from localhost ([::1]:35594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiKhs-0008E0-Dh for importer@patchew.org; Mon, 08 Jun 2020 12:33:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiKI1-0002gw-61 for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:06:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25227 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jiKI0-0000Fg-1P for qemu-devel@nongnu.org; Mon, 08 Jun 2020 12:06:20 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-6HbYzaKfOuCYxe-G1LFokA-1; Mon, 08 Jun 2020 12:06:15 -0400 Received: by mail-wr1-f72.google.com with SMTP id d6so7343766wrn.1 for ; Mon, 08 Jun 2020 09:06:15 -0700 (PDT) Received: from localhost.localdomain (181.red-88-10-103.dynamicip.rima-tde.net. [88.10.103.181]) by smtp.gmail.com with ESMTPSA id j4sm48617wma.7.2020.06.08.09.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 09:06:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591632379; 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; bh=IQ2Zwmt+Uey5o0Uah3Zvdno8y42e5J5YjRZjcD6UUkc=; b=BPDfi87CHOysbUP2eYSpqIkK6sV5T6M6cSB+Ar5y1KMAyDkZuLdMXYAwcrUZwy1WjQxCL0 GxXPNGwwoVeIVkZUjoqOMzm9iEAhIc3JyZDwan8wFNixwWCU9Tag6pqCELUL5xFmipLHg6 mj809kfge3jdCcoktyKzgZmzXEPFxVk= X-MC-Unique: 6HbYzaKfOuCYxe-G1LFokA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IQ2Zwmt+Uey5o0Uah3Zvdno8y42e5J5YjRZjcD6UUkc=; b=S9Cyl+lK+jLEwabC/NprPq0S25rV/6Y+RPWewrtY9zypQvBQG1ZUT8is1ApKEblLgS LQ8KMnDfLFfFGeLEWMuJ+ijLp/BXm7bBfZMygEapp126fCYbzH9f0p1YqwF3jJDXFGwM QzejFB+jP76Qf7Yc95rOyGFDJz2wJXyap7cUPVrB7Ol//rHZYeJ6eJ4HJlATTKH5N2q8 1hJ5KhO0PDT7gUJYYJ2vjHfLcEFVjHhdutPF2JqJvdXDF4jQRgfORNOhmae6emWwb+Yc CYQX8F/8ZDa4THlhtkEDbqOqelfOC6WbCDCZIu6Plt8rn8x7SQKCASlkfyh2B6AS3XS1 s1Hg== X-Gm-Message-State: AOAM5311N0NfpdsF/fgFaRBxuF6i5ddUqQ7Hl6KxU7862eUNEgKvpqxt kp6FspHCgXxRi0FZl8s2FYVIQ8k3fcki828NfwHwuqKaYqRTtvHvJerTswUqh3s6AUZpehQiauE dk8HVTJM47Dl4oIY= X-Received: by 2002:a05:6000:1104:: with SMTP id z4mr24024570wrw.272.1591632374450; Mon, 08 Jun 2020 09:06:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPKGJLisyMOH/ojvihDYa0lan6gnwMhb7yaO/6lsrH3bKYJhiQTZOhUJwlTONMDJsyX94C8g== X-Received: by 2002:a05:6000:1104:: with SMTP id z4mr24024548wrw.272.1591632374222; Mon, 08 Jun 2020 09:06:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?UTF-8?q?Martin=20Li=C5=A1ka?= , Eric Blake Subject: [PATCH v2] hw/openrisc/openrisc_sim: Add assertion to silence GCC warning Date: Mon, 8 Jun 2020 18:06:11 +0200 Message-Id: <20200608160611.16966-1-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; 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=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/08 05:40:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: Peter Maydell , Thomas Huth , Jia Liu , qemu-trivial@nongnu.org, Markus Armbruster , 1874073@bugs.launchpad.net, Christophe de Dinechin , Stafford Horne , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) When compiling with GCC 10 (Fedora 32) using CFLAGS=3D-O2 we get: CC or1k-softmmu/hw/openrisc/openrisc_sim.o hw/openrisc/openrisc_sim.c: In function =E2=80=98openrisc_sim_init=E2=80= =99: hw/openrisc/openrisc_sim.c:87:42: error: =E2=80=98cpu_irqs[0]=E2=80=99 ma= y be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 87 | sysbus_connect_irq(s, i, cpu_irqs[i][irq_pin]); | ~~~~~~~~^~~ While humans can tell smp_cpus will always be in the [1, 2] range, (openrisc_sim_machine_init sets mc->max_cpus =3D 2), the compiler can't. Add an assertion to give the compiler a hint there's no use of uninitialized data. Buglink: https://bugs.launchpad.net/qemu/+bug/1874073 Reported-by: Martin Li=C5=A1ka Suggested-by: Peter Maydell Reviewed-by: Thomas Huth Tested-by: Eric Blake Reviewed-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- v2: Fixed typo in subject (eblake) Supersedes: <20200608071409.17024-1-philmd@redhat.com> --- hw/openrisc/openrisc_sim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index d08ce61811..02f5259e5e 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -134,6 +134,7 @@ static void openrisc_sim_init(MachineState *machine) int n; unsigned int smp_cpus =3D machine->smp.cpus; =20 + assert(smp_cpus >=3D 1 && smp_cpus <=3D 2); for (n =3D 0; n < smp_cpus; n++) { cpu =3D OPENRISC_CPU(cpu_create(machine->cpu_type)); if (cpu =3D=3D NULL) { --=20 2.21.3