From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 225BAC433E0 for ; Mon, 8 Jun 2020 15:34:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0AE8206D5 for ; Mon, 8 Jun 2020 15:34:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HTtV6h5A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0AE8206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiJnE-000057-6y for qemu-devel@archiver.kernel.org; Mon, 08 Jun 2020 11:34:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiJmK-0007pE-LS for qemu-devel@nongnu.org; Mon, 08 Jun 2020 11:33:36 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21162 helo=us-smtp-delivery-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 1jiJmJ-00021o-Pd for qemu-devel@nongnu.org; Mon, 08 Jun 2020 11:33:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591630414; 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=oxWQ4bhEfnQYH5cmCr4iZSh4Wrs0FK3XYt4YmOQiIF8=; b=HTtV6h5AiJunZA1hIMHhOKxY8GTnuzLbDU3UpQoz0o6xP+OLzp0msGXTEN4kfuDrrflng6 E6c1sqWyxffA+HetHoB3rQxctgha6D7QRnTJZbyhEZKKtJ0/kxTP0mBzOm6SNUJPTZxPd/ GCQS3hEfyWLlabOthdI+A5BghICg/lo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-mFA6yMqTMYmE-5BbQyBlwA-1; Mon, 08 Jun 2020 11:33:30 -0400 X-MC-Unique: mFA6yMqTMYmE-5BbQyBlwA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A982E108BD0C; Mon, 8 Jun 2020 15:33:28 +0000 (UTC) Received: from [10.3.113.22] (ovpn-113-22.phx2.redhat.com [10.3.113.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1EAEC891E6; Mon, 8 Jun 2020 15:33:25 +0000 (UTC) Subject: Re: [PATCH] hw/openrisc/openrisc_sim: Add assertion to silent GCC warning To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-devel@nongnu.org, =?UTF-8?Q?Martin_Li=c5=a1ka?= References: <20200608071409.17024-1-philmd@redhat.com> From: Eric Blake Organization: Red Hat, Inc. Message-ID: <95f1d638-3921-ffdf-8f07-2f077d1d0cc9@redhat.com> Date: Mon, 8 Jun 2020 10:33:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200608071409.17024-1-philmd@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=207.211.31.81; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/08 05:40:44 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_H4=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 Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 6/8/20 2:14 AM, Philippe Mathieu-Daudé wrote: > When compiling with GCC 10 (Fedora 32) using CFLAGS=-O2 we get: In the subject: s/silent/silence/ > > CC or1k-softmmu/hw/openrisc/openrisc_sim.o > hw/openrisc/openrisc_sim.c: In function ‘openrisc_sim_init’: > hw/openrisc/openrisc_sim.c:87:42: error: ‘cpu_irqs[0]’ may be used uninitialized in this function [-Werror=maybe-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 = 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ška > Suggested-by: Peter Maydell > Signed-off-by: Philippe Mathieu-Daudé > --- > hw/openrisc/openrisc_sim.c | 1 + > 1 file changed, 1 insertion(+) Tested-by: Eric Blake With the typo fixed, Reviewed-by: Eric Blake -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33DF7C433E0 for ; Mon, 8 Jun 2020 15:43:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07C43206C3 for ; Mon, 8 Jun 2020 15:43:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07C43206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bugs.launchpad.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jiJvt-0006Z5-BU for qemu-devel@archiver.kernel.org; Mon, 08 Jun 2020 11:43:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiJtd-00049r-On for qemu-devel@nongnu.org; Mon, 08 Jun 2020 11:41:10 -0400 Received: from indium.canonical.com ([91.189.90.7]:44814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jiJtc-0003j2-Ax for qemu-devel@nongnu.org; Mon, 08 Jun 2020 11:41:09 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.86_2 #2 (Debian)) id 1jiJta-0004Qd-Ei for ; Mon, 08 Jun 2020 15:41:06 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 6760C2E8105 for ; Mon, 8 Jun 2020 15:41:06 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Mon, 08 Jun 2020 15:33:24 -0000 From: Eric Blake <1874073@bugs.launchpad.net> To: qemu-devel@nongnu.org X-Launchpad-Notification-Type: bug X-Launchpad-Bug: product=qemu; status=Confirmed; importance=Undecided; assignee=philmd@redhat.com; X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: eblake mliska philmd pmaydell X-Launchpad-Bug-Reporter: Martin Liska (mliska) X-Launchpad-Bug-Modifier: Eric Blake (eblake) References: <158747496330.1952.6391008472811579405.malonedeb@chaenomeles.canonical.com> <20200608071409.17024-1-philmd@redhat.com> Message-ID: <95f1d638-3921-ffdf-8f07-2f077d1d0cc9@redhat.com> Subject: [Bug 1874073] Re: [PATCH] hw/openrisc/openrisc_sim: Add assertion to silent GCC warning X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml X-Launchpad-Message-For: qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="ef9fc486e875d54078fa61cf91e898b895125d89"; Instance="production-secrets-lazr.conf" X-Launchpad-Hash: 9b336a1c57938e582a6fc0c6bd79410aa3d01d41 Received-SPF: none client-ip=91.189.90.7; envelope-from=bounces@canonical.com; helo=indium.canonical.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/08 11:30:42 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -65 X-Spam_score: -6.6 X-Spam_bar: ------ X-Spam_report: (-6.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bug 1874073 <1874073@bugs.launchpad.net> Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20200608153324.mEAOL1fLY86y7oUUV5j0HNzQ_wih0T38olyEu10SFmc@z> On 6/8/20 2:14 AM, Philippe Mathieu-Daud=C3=A9 wrote: > When compiling with GCC 10 (Fedora 32) using CFLAGS=3D-O2 we get: In the subject: s/silent/silence/ > = > 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= may 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 > Signed-off-by: Philippe Mathieu-Daud=C3=A9 > --- > hw/openrisc/openrisc_sim.c | 1 + > 1 file changed, 1 insertion(+) Tested-by: Eric Blake With the typo fixed, Reviewed-by: Eric Blake -- = Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1874073 Title: openrisc_sim.c:87:42: error: 'cpu_irqs[0]' may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] Status in QEMU: Confirmed Bug description: I see the warning since gcc10: static void openrisc_sim_init(MachineState *machine): ... qemu_irq *cpu_irqs[2]; ... = serial_mm_init(get_system_memory(), 0x90000000, 0, serial_irq, 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); I would initialize cpu_irqs[2] with {}. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1874073/+subscriptions