public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation•org>
To: Brahmajit <brahmajit.xyz@gmail•com>
Cc: Stephen Rothwell <sfr@canb•auug.org.au>,
	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: Fri, 4 Oct 2024 14:58:04 -0700	[thread overview]
Message-ID: <20241004145804.57278eac01c2601abb20c671@linux-foundation.org> (raw)
In-Reply-To: <wdpe6qft3ucqxpd6gyvz6pol5ct44g64b3azmnjxtv7buemk3q@kgxvzoxdx6pm>

On Sat, 5 Oct 2024 02:42:12 +0530 Brahmajit <brahmajit.xyz@gmail•com> wrote:

> With Andrew's suggestion I came up with something like this, would love
> some feedback.
> 
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -909,8 +909,15 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
>  {
>  	/*
>  	 * Don't forget to update Documentation/ on changes.
> +	 *
> +	 * The length of the second argument of mnemonics[]
> +	 * needs to be 3 instead of previously set 2
> +	 * (i.e. from [BITS_PER_LONG][2] to [BITS_PER_LONG][3])
> +	 * to avoid spurious
> +	 * -Werror=unterminated-string-initialization warning
> +	 *  with GCC 15
>  	 */
> -	static const char mnemonics[BITS_PER_LONG][2] = {
> +	static const char mnemonics[BITS_PER_LONG][3] = {
>  		/*
>  		 * In case if we meet a flag we don't know about.
>  		 */
> @@ -985,13 +992,10 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
>  
>  	seq_puts(m, "VmFlags: ");
>  	for (i = 0; i < BITS_PER_LONG; i++) {
> -		if (!mnemonics[i][0])
> +		if (strcmp(mnemonics[i], "") == 0)
>  			continue;

lgtm, except this change isn't needed - testing the 0th char for NULL
is a common idiom.


> -		if (vma->vm_flags & (1UL << i)) {
> -			seq_putc(m, mnemonics[i][0]);
> -			seq_putc(m, mnemonics[i][1]);
> -			seq_putc(m, ' ');
> -		}
> +		if (vma->vm_flags & (1UL << i))
> +			seq_printf(m, "%s ", mnemonics[i]);
>  	}
>  	seq_putc(m, '\n');
>  }


  reply	other threads:[~2024-10-04 21:58 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
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 [this message]
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=20241004145804.57278eac01c2601abb20c671@linux-foundation.org \
    --to=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 \
    --cc=sfr@canb$(echo .)auug.org.au \
    /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