From: Al Viro <viro@zeniv.linux.org.uk>
To: Brahmajit <brahmajit.xyz@gmail.com>
Cc: chaosman@ontika.net, linux-kernel <linux-kernel@vger.kernel.org>,
Christian Brauner <brauner@kernel.org>
Subject: Re: Build failure with GCC 15 due to -Werror=unterminated-string-initialization
Date: Wed, 2 Oct 2024 22:46:56 +0100 [thread overview]
Message-ID: <20241002214656.GG4017910@ZenIV> (raw)
In-Reply-To: <ytw2hroanhyyvrh2ps24l2a6qsdke5m67ynfqcqpzo7wgp3ibv@spvsq3mzltnk>
On Thu, Oct 03, 2024 at 02:46:48AM +0530, Brahmajit wrote:
> I'm building the latest kernel with GCC 15 and got this build failure
>
> fs/qnx6/inode.c: In function ‘qnx6_checkroot’:
> fs/qnx6/inode.c:182:41: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
> 182 | static char match_root[2][3] = {".\0\0", "..\0"};
> | ^~~~~~~
> fs/qnx6/inode.c:182:50: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
> 182 | static char match_root[2][3] = {".\0\0", "..\0"};
> | ^~~~~~
>
> This is due to GCC 15 now enables
> -Werror=unterminated-string-initialization by default.
> This is not the only error, there are many such build failures in
> various subsystems, some of theme are easy to fix, while some are not.
> In this case I was thinking of something like:
>
> --- a/fs/qnx6/inode.c
> +++ b/fs/qnx6/inode.c
> @@ -179,7 +179,7 @@ static int qnx6_statfs(struct dentry *dentry, struct kstatfs *buf)
> */
> static const char *qnx6_checkroot(struct super_block *s)
> {
> - static char match_root[2][3] = {".\0\0", "..\0"};
> + static char *match_root[][3] = {".\0\0", "..\0"};
Huh? That makes no sense whatsoever - you get a single-element
array of 3-element arrays of pointers to char.
What you have written is equivalent to
static char *s1 = ".\0\0";
static char *s2 = "..\0";
static char *match_root[1][3] = {[0][0] = s1, [0][1] = s2, [0][2] = NULL};
and match_root[0] is *NOT* a pointer to char anymore.
Just lose the last \0 in each of those string literals...
next prev parent reply other threads:[~2024-10-02 21:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 21:16 Build failure with GCC 15 due to -Werror=unterminated-string-initialization Brahmajit
2024-10-02 21:46 ` Al Viro [this message]
2024-10-02 21:54 ` Al Viro
2024-10-03 6:52 ` Brahmajit
2024-10-04 9:49 ` [PATCH 1/1] fs/qnx6: Fix building with GCC 15 Brahmajit Das
2024-10-04 18:44 ` Al Viro
2024-10-04 19:51 ` Brahmajit
2024-10-04 19:51 ` [PATCH v2 " Brahmajit Das
2024-11-15 5:03 ` Al Viro
2024-12-02 4:29 ` Al Viro
2024-12-03 9:41 ` Christian Brauner
2024-10-06 19:38 ` [PATCH " David Laight
2024-10-06 20:00 ` Al Viro
2024-10-06 23:05 ` Brahmajit
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=20241002214656.GG4017910@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brahmajit.xyz@gmail.com \
--cc=brauner@kernel.org \
--cc=chaosman@ontika.net \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.