Message ID | ZJTcvfpvhvF+OLjc@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5417590vqr; Thu, 22 Jun 2023 16:55:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/kwgDsrlAqZ+DIiWxLeYNq/DF6z8G6Hj4Es2bISGUOZ/+g9M4RZuNiyQYyFILL41WAyZc X-Received: by 2002:a05:6a20:7da1:b0:123:9582:e9fb with SMTP id v33-20020a056a207da100b001239582e9fbmr4877542pzj.50.1687478101786; Thu, 22 Jun 2023 16:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687478101; cv=none; d=google.com; s=arc-20160816; b=EMn4+quXW56Gz3FUZZSiCYMcE4s4gfY3/h+/Y0Xq5ksTyI35mRWrHuznB05An6yfqI yfzW5t9yDv2WtNjoA/cyUL84jsGPUQb4LoB4Ell9QmRKYmE2fyxIpQbbqCc04TaRhHJZ uiZM7pqkkuAiWs1WYVEJ2/28FOu8F9/91nHiYHyMBp/bGCcoLatSGTd0wBZQ65D8naBB VgH6f/ETGSlDsC46XQndqJNNbVCebl/qLuvYIB7l5O2kQkuNLeDWDxe+ZGbV/QCGPqJN VbW0wiMpIMGNR9ZWbN0hbV9Qbjj1pRBsEFLDsazikJkISXro5D0TxTzZ2Cbiioa8BJGZ LNaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=V/UN0w+ssVx1bsFEljxHq+DZQmV8Wk7sInd9hHQQDIs=; b=zGqO7EgK5y5XsI8SMSkreeK4eQT+N5C40O2dQwvdH6GXSPtCjiWBLiPpOcaliOXDYp pS5IrFpGyRh0Qw0fufK5+nh9YZdH+6eYO8F2c175SvbVD5jvbqvmaVn3HeDv6nR42Asu 0CNKBh3EnVDJTxpJ2inc+qT3y634/qpsMh2kNL3VWcuB5iGqpfzP2WYKIQJTHbUx34oF 4Za/vHIq/SZrXBLO+8iGClkasD8JMLW7ka/sE87YiU+DuCl+KF+180fN7osCWWM8Bwiv 6ZVjvxcPdvtmOq5kIUYzEviUOdJxlDy6ugEJIWewsOTizdHdxvxYqGkIfDa2qXdn4j6p D3DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XPuPi2nR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be8-20020a170902aa0800b001b3414a1fa9si7468106plb.175.2023.06.22.16.54.47; Thu, 22 Jun 2023 16:55:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XPuPi2nR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231734AbjFVXnF (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Thu, 22 Jun 2023 19:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbjFVXnE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Jun 2023 19:43:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2542121; Thu, 22 Jun 2023 16:43:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 650D661710; Thu, 22 Jun 2023 23:43:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D7A8C433C8; Thu, 22 Jun 2023 23:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687477381; bh=XiHdQW2COChuhdW8/pHNZiGOCWZC/cyIHQHJxwAaX/w=; h=Date:From:To:Cc:Subject:From; b=XPuPi2nRjJ1ZKqb8yiXgAFJRBNAh6RfTKlUPPDka5LPaOpshTka603rNJuU+b4y2m ljolB9PryWxis7ZnW5nFJaw1HMfbgeSkAwDA3Sa0K6OO8pXiGYyrsq5zsJRcGPc4Vn 6h6aPvzWpPKlfR7i50bq7i9w4l0//9U0t1ROgvG/91lJQ8UwSe+TvN/oUVesRG9lHN 0lcoLWBGCaqJi+DQ1Cd7F/I8UL4pOvv8pI/1rllpFNr5UHMHmlk5x78DUkVtiioOix OyJK4eEnRv3RVNEyD2V08kzKG//OH42lrGCImJxknwqypnT75CzHyECwtT+aFYDaOl rpGcJXJg2iKVw== Date: Thu, 22 Jun 2023 17:43:57 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: "Maciej W. Rozycki" <macro@orcam.me.uk>, Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] MIPS: dec: prom: Address -Warray-bounds warning Message-ID: <ZJTcvfpvhvF+OLjc@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769449038165890951?= X-GMAIL-MSGID: =?utf-8?q?1769449038165890951?= |
Series |
[next] MIPS: dec: prom: Address -Warray-bounds warning
|
|
Commit Message
Gustavo A. R. Silva
June 22, 2023, 11:43 p.m. UTC
Zero-length arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace zero-length array with flexible-array
member in struct memmap.
Address the following warning found after building (with GCC-13) mips64
with decstation_64_defconfig:
In function 'rex_setup_memory_region',
inlined from 'prom_meminit' at arch/mips/dec/prom/memory.c:91:3:
arch/mips/dec/prom/memory.c:72:31: error: array subscript i is outside array bounds of 'unsigned char[0]' [-Werror=array-bounds=]
72 | if (bm->bitmap[i] == 0xff)
| ~~~~~~~~~~^~~
In file included from arch/mips/dec/prom/memory.c:16:
./arch/mips/include/asm/dec/prom.h: In function 'prom_meminit':
./arch/mips/include/asm/dec/prom.h:73:23: note: while referencing 'bitmap'
73 | unsigned char bitmap[0];
This helps with the ongoing efforts to globally enable -Warray-bounds.
This results in no differences in binary output.
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/323
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
arch/mips/include/asm/dec/prom.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Jun 22, 2023 at 05:43:57PM -0600, Gustavo A. R. Silva wrote: > Zero-length arrays are deprecated, and we are replacing them with flexible > array members instead. So, replace zero-length array with flexible-array > member in struct memmap. > > Address the following warning found after building (with GCC-13) mips64 > with decstation_64_defconfig: > In function 'rex_setup_memory_region', > inlined from 'prom_meminit' at arch/mips/dec/prom/memory.c:91:3: > arch/mips/dec/prom/memory.c:72:31: error: array subscript i is outside array bounds of 'unsigned char[0]' [-Werror=array-bounds=] > 72 | if (bm->bitmap[i] == 0xff) > | ~~~~~~~~~~^~~ > In file included from arch/mips/dec/prom/memory.c:16: > ./arch/mips/include/asm/dec/prom.h: In function 'prom_meminit': > ./arch/mips/include/asm/dec/prom.h:73:23: note: while referencing 'bitmap' > 73 | unsigned char bitmap[0]; > > This helps with the ongoing efforts to globally enable -Warray-bounds. > > This results in no differences in binary output. > > Link: https://github.com/KSPP/linux/issues/79 > Link: https://github.com/KSPP/linux/issues/323 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > --- > arch/mips/include/asm/dec/prom.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/mips/include/asm/dec/prom.h b/arch/mips/include/asm/dec/prom.h > index 1e1247add1cf..908e96e3a311 100644 > --- a/arch/mips/include/asm/dec/prom.h > +++ b/arch/mips/include/asm/dec/prom.h > @@ -70,7 +70,7 @@ static inline bool prom_is_rex(u32 magic) > */ > typedef struct { > int pagesize; > - unsigned char bitmap[0]; > + unsigned char bitmap[]; > } memmap; > > > -- > 2.34.1 applied to mips-next. Thomas.
On Fri, 23 Jun 2023, Thomas Bogendoerfer wrote: > > Zero-length arrays are deprecated, and we are replacing them with flexible > > array members instead. So, replace zero-length array with flexible-array > > member in struct memmap. Technically it is a semantics bug fix actually, as the TURBOchannel firmware specification (from Jan 1993) says it's: typedef struct{ int pagesize; unsigned char bitmap[];}memmap; int getbitmap(memmap *map); (formatting preserved as in the document) so it should have always been a flexible array member. Maybe old (2.x) GCC versions had an issue with it or something, as otherwise I can't imagine why whoever added our typedef did it differently from the spec. > applied to mips-next. Not sure if you can retrofit it, but: Acked-by: Maciej W. Rozycki <macro@orcam.me.uk> Maciej
On 6/23/23 07:41, Maciej W. Rozycki wrote: > On Fri, 23 Jun 2023, Thomas Bogendoerfer wrote: > >>> Zero-length arrays are deprecated, and we are replacing them with flexible >>> array members instead. So, replace zero-length array with flexible-array >>> member in struct memmap. > > Technically it is a semantics bug fix actually, as the TURBOchannel > firmware specification (from Jan 1993) says it's: > > typedef struct{ int pagesize; unsigned char bitmap[];}memmap; > int getbitmap(memmap *map); > > (formatting preserved as in the document) so it should have always been a > flexible array member. Maybe old (2.x) GCC versions had an issue with it > or something, as otherwise I can't imagine why whoever added our typedef > did it differently from the spec. Apparently, flexible-array members were supported in some 2.x versions as an extension to the language; and it was not until GCC 3.0 that they were fully supported by the compiler. > >> applied to mips-next. > > Not sure if you can retrofit it, but: > > Acked-by: Maciej W. Rozycki <macro@orcam.me.uk> Thanks! -- Gustavo
diff --git a/arch/mips/include/asm/dec/prom.h b/arch/mips/include/asm/dec/prom.h index 1e1247add1cf..908e96e3a311 100644 --- a/arch/mips/include/asm/dec/prom.h +++ b/arch/mips/include/asm/dec/prom.h @@ -70,7 +70,7 @@ static inline bool prom_is_rex(u32 magic) */ typedef struct { int pagesize; - unsigned char bitmap[0]; + unsigned char bitmap[]; } memmap;