From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: "Maciej W. Rozycki" <macro@orcam.me.uk>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] MIPS: dec: prom: Address -Warray-bounds warning
Date: Fri, 23 Jun 2023 15:10:19 +0200 [thread overview]
Message-ID: <20230623131019.GD11636@alpha.franken.de> (raw)
In-Reply-To: <ZJTcvfpvhvF+OLjc@work>
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.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
next prev parent reply other threads:[~2023-06-23 13:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 23:43 [PATCH][next] MIPS: dec: prom: Address -Warray-bounds warning Gustavo A. R. Silva
2023-06-23 13:10 ` Thomas Bogendoerfer [this message]
2023-06-23 13:41 ` Maciej W. Rozycki
2023-06-23 14:14 ` Gustavo A. R. Silva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230623131019.GD11636@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@orcam.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox