mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brahmajit Das <brahmajit.xyz@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: brauner@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] fs/qnx6: Fix building with GCC 15
Date: Fri,  4 Oct 2024 15:19:21 +0530	[thread overview]
Message-ID: <20241004094921.615688-1-brahmajit.xyz@gmail.com> (raw)
In-Reply-To: <vch6gmzqaeo22c7473qyabrfwxlkdhx5vgvosjyp5l2nwgqnxl@5x3ny35qyfgx>

GCC 15 enables -Werror=unterminated-string-initialization by default.
This results in the following build error

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"};
      |                                                  ^~~~~~

Dropping to match_root array and drictly comparing dir_entry entries via
memcmp provides a work aroud for the build error.

Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
---
 fs/qnx6/inode.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index 85925ec0051a..3310d1ad4d0e 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -179,8 +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"};
-	int i, error = 0;
+	int error = 0;
 	struct qnx6_dir_entry *dir_entry;
 	struct inode *root = d_inode(s->s_root);
 	struct address_space *mapping = root->i_mapping;
@@ -189,11 +188,9 @@ static const char *qnx6_checkroot(struct super_block *s)
 	if (IS_ERR(folio))
 		return "error reading root directory";
 	dir_entry = kmap_local_folio(folio, 0);
-	for (i = 0; i < 2; i++) {
-		/* maximum 3 bytes - due to match_root limitation */
-		if (strncmp(dir_entry[i].de_fname, match_root[i], 3))
-			error = 1;
-	}
+	if (memcmp(dir_entry[0].de_fname, ".", 2) ||
+	    memcmp(dir_entry[1].de_fname, "..", 3))
+		error = 1;
 	folio_release_kmap(folio, dir_entry);
 	if (error)
 		return "error reading root directory.";
-- 
2.46.2


  reply	other threads:[~2024-10-04  9:49 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
2024-10-02 21:54   ` Al Viro
2024-10-03  6:52     ` Brahmajit
2024-10-04  9:49       ` Brahmajit Das [this message]
2024-10-04 18:44         ` [PATCH 1/1] fs/qnx6: Fix building with GCC 15 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=20241004094921.615688-1-brahmajit.xyz@gmail.com \
    --to=brahmajit.xyz@gmail.com \
    --cc=brauner@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®