public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb•auug.org.au>
To: Andrew Morton <akpm@linux-foundation•org>
Cc: Brahmajit Das <brahmajit.xyz@gmail•com>,
	david@redhat•com, gorcunov@openvz•org,
	linux-next@vger•kernel.org
Subject: Re: [PATCH v2 1/1] fs: proc: Fix build with GCC 15 due to -Werror=unterminated-string-initialization
Date: Thu, 3 Oct 2024 09:30:40 +1000	[thread overview]
Message-ID: <20241003093040.47c08382@canb.auug.org.au> (raw)
In-Reply-To: <20241002144806.255d62115286e173bbf42655@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 1895 bytes --]

Hi Andrew,

On Wed, 2 Oct 2024 14:48:06 -0700 Andrew Morton <akpm@linux-foundation•org> wrote:
>
> On Wed,  2 Oct 2024 13:39:14 +0530 Brahmajit Das <brahmajit.xyz@gmail•com> 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2024-10-02 23:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02  8:05 [PATCH 1/1] fs: proc: Fix build with GCC 15 due to -Werror=unterminated-string-initialization Brahmajit Das
2024-10-02  8:09 ` [PATCH v2 " Brahmajit Das
2024-10-02 21:48   ` Andrew Morton
2024-10-02 23:30     ` Stephen Rothwell [this message]
2024-10-02 23:39     ` Stephen Rothwell
2024-10-04 20:16     ` Brahmajit
2024-10-04 21:12     ` Brahmajit
2024-10-04 21:58       ` Andrew Morton
2024-10-05  6:37         ` [PATCH v3 1/1] fs/proc: " Brahmajit Das
2024-10-08  2:08           ` Andrew Morton
2024-10-28  8:02             ` Cyrill Gorcunov

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=20241003093040.47c08382@canb.auug.org.au \
    --to=sfr@canb$(echo .)auug.org.au \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=brahmajit.xyz@gmail$(echo .)com \
    --cc=david@redhat$(echo .)com \
    --cc=gorcunov@openvz$(echo .)org \
    --cc=linux-next@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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