Subject: Re: [PATCH v2 1/1] fs: proc: Fix build with GCC 15 due to -Werror=unterminated-string-initialization

From: Stephen Rothwell <[email-masked]>
Date: Thu, 3 Oct 2024 09:30:40 +1000

Hi Andrew,

On Wed, 2 Oct 2024 14:48:06 -0700 Andrew Morton <[email-masked]> wrote:
>
> On Wed,  2 Oct 2024 13:39:14 +0530 Brahmajit Das <[email-masked]> wrote:
> 
> > GCC 15 enables -Werror=unterminated-string-initialization by default.
> > This results in the following build error/s
> > fs/proc/task_mmu.c:917:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminate d-string-initialization]
> >   917 |                 [0 ... (BITS_PER_LONG-1)] = "??",
> >       |                                                 ^~~~
> > fs/proc/task_mmu.c:917:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminate d-string-initialization]
> > fs/proc/task_mmu.c:917:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminate d-string-initialization]
> > fs/proc/task_mmu.c:917:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminate d-string-initialization]
> > fs/proc/task_mmu.c:917:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminate d-string-initialization]
> > fs/proc/task_mmu.c:917:49: error: initializer-string for array of ‘char’ is too long [-Werror=unterminate d-string-initialization]
> > ...
> > 
> > To fix this, the length of the second argument of arary mnemonics needs  
> 
> "array"
> 
> > to be 3 instead of previously set 2 (i.e. from [BITS_PER_LONG][2] to
> > [BITS_PER_LONG][3])
> >   
> 
> Yes, I'm not surprised that little party trick we used in there fools
> gcc.  And really it deserves to die.

However, the C standard explicitly allows for a string initializer to
be too long due to the NUL byte at the end ... so this warning may be
over zealous. And the code referencing these "strings" was deliberately
written to be correct.

-- 
Cheers,
Stephen Rothwell