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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrew,

On Wed, 2 Oct 2024 14:48:06 -0700 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed,  2 Oct 2024 13:39:14 +0530 Brahmajit Das <brahmajit.xyz@xxxxxxxxx> 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

Attachment: pgp3lgj7sFycm.pgp
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux