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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 1ECBCC4363A for ; Mon, 26 Oct 2020 16:24:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 B9E6E22284 for ; Mon, 26 Oct 2020 16:24:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HUIw6fk+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9E6E22284 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YWsC8PuwStqSsLM6xkz/CrHViLqYolGyjJ4lj4Axctk=; b=HUIw6fk+1n1Z70UTVbhFQXQvY WLLMHLKvbE3P9NrgEjn1wp1ioVMFnfRp4YeHpPHCqovtP6F5AbIXk+NTDdR0jWGJI5P3TZvlVxitX X1wn40jaAAsZpLMVzoKhVSHLRNHsMfoBf4RDid4QdtE0RTaPAHf88iVhyXPPn7x+T/oY0XsFGl8R2 7MRWJT/3YQ4i3/IW4uRP9m0lNK828IPA6vqD5GT9Z1Cjbj3N8X009ZlkupBYIFl6Ruvpao/nQkgz3 q5mTdlIcHG/YVqUDiWljfiQmHRtuGnYSNfapTjhSwVsLu3pGOGQrHDHrpljCIy6vcW0EK4JLj7epP g4FZh2oYw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX5HK-00078U-Cq; Mon, 26 Oct 2020 16:23:26 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kX5HI-00077g-5M for linux-arm-kernel@lists.infradead.org; Mon, 26 Oct 2020 16:23:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 920E81042; Mon, 26 Oct 2020 09:23:22 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.56.187]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 257703F719; Mon, 26 Oct 2020 09:23:20 -0700 (PDT) Date: Mon, 26 Oct 2020 16:23:14 +0000 From: Mark Rutland To: Arnd Bergmann Subject: Re: [PATCH 4/4] arm64: traps: fix -Woverride-init warnings Message-ID: <20201026162314.GA42396@C02TD0UTHF1T.local> References: <20201026160342.3705327-1-arnd@kernel.org> <20201026160342.3705327-4-arnd@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201026160342.3705327-4-arnd@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201026_122324_311011_90060880 X-CRM114-Status: GOOD ( 25.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gavin Shan , Arnd Bergmann , Marc Zyngier , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Mark Brown , James Morse , linux-arm-kernel@lists.infradead.org, Dmitry Safonov <0x7f454c46@gmail.com>, Amit Daniel Kachhap , Will Deacon , Dave Martin , Christoffer Dall Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Arnd, On Mon, Oct 26, 2020 at 05:03:31PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > There are many warnings in this file when we re-enable the > Woverride-init flag: > > arch/arm64/kernel/traps.c:704:26: warning: initialized field overwritten [-Woverride-init] > 704 | [ESR_ELx_EC_UNKNOWN] = "Unknown/Uncategorized", > | ^~~~~~~~~~~~~~~~~~~~~~~ > arch/arm64/kernel/traps.c:704:26: note: (near initialization for 'esr_class_str[0]') > arch/arm64/kernel/traps.c:705:22: warning: initialized field overwritten [-Woverride-init] > 705 | [ESR_ELx_EC_WFx] = "WFI/WFE", > | ^~~~~~~~~ > > This is harmless since they are only informational strings, > but it's easy to change the code to ignore missing initialization > and instead warn about possible duplicate initializers. This has come up before, and IMO the warning is more hindrance than helpful, given the prevalance of spurious warnings, and the (again IMO) the rework needed to avoid those making the code harder to reason about. We use this pattern all througout the kernel (e.g. in the syscall wrappers), so unless the plan is to avoid this everywhere, I don't think that we should alter individual cases. I also don't think that the Fixes tag is appropriate given the code is correct. Could we instead convince the compiler folk to give us better tools to deal with this? For example, if we could annotate assignmments as overridable or being an override, it'd be possible to distinguish the benign cases from bad ones, without forcing us to have dynamic checks. Thanks, Mark. > > Fixes: 60a1f02c9e91 ("arm64: decode ESR_ELx.EC when reporting exceptions") > Signed-off-by: Arnd Bergmann > --- > arch/arm64/kernel/traps.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index 8af4e0e85736..d21cb25f9e1f 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -700,7 +700,6 @@ void do_sysinstr(unsigned int esr, struct pt_regs *regs) > NOKPROBE_SYMBOL(do_sysinstr); > > static const char *esr_class_str[] = { > - [0 ... ESR_ELx_EC_MAX] = "UNRECOGNIZED EC", > [ESR_ELx_EC_UNKNOWN] = "Unknown/Uncategorized", > [ESR_ELx_EC_WFx] = "WFI/WFE", > [ESR_ELx_EC_CP15_32] = "CP15 MCR/MRC", > @@ -746,7 +745,7 @@ static const char *esr_class_str[] = { > > const char *esr_get_class_string(u32 esr) > { > - return esr_class_str[ESR_ELx_EC(esr)]; > + return esr_class_str[ESR_ELx_EC(esr)] ?: "UNRECOGNIZED EC"; > } > > /* > -- > 2.27.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel