Skip to content

Commit 989e0cd

Browse files
Brahmajit Dasbrauner
authored andcommitted
fs/qnx6: Fix building with GCC 15
qnx6_checkroot() had been using weirdly spelled initializer - it needed to initialize 3-element arrays of char and it used NUL-padded 3-character string literals (i.e. 4-element initializers, with completely pointless zeroes at the end). That had been spotted by gcc-15[*]; prior to that gcc quietly dropped the 4th element of initializers. However, none of that had been needed in the first place - all this array is used for is checking that the first directory entry in root directory is "." and the second - "..". The check had been expressed as a loop, using that match_root[] array. Since there is no chance that we ever want to extend that list of entries, the entire thing is much too fancy for its own good; what we need is just a couple of explicit memcmp() and that's it. [*]: 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"}; | ^~~~~~ Signed-off-by: Brahmajit Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Al Viro <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent b905baf commit 989e0cd

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

fs/qnx6/inode.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ static int qnx6_statfs(struct dentry *dentry, struct kstatfs *buf)
179179
*/
180180
static const char *qnx6_checkroot(struct super_block *s)
181181
{
182-
static char match_root[2][3] = {".\0\0", "..\0"};
183-
int i, error = 0;
182+
int error = 0;
184183
struct qnx6_dir_entry *dir_entry;
185184
struct inode *root = d_inode(s->s_root);
186185
struct address_space *mapping = root->i_mapping;
@@ -189,11 +188,9 @@ static const char *qnx6_checkroot(struct super_block *s)
189188
if (IS_ERR(folio))
190189
return "error reading root directory";
191190
dir_entry = kmap_local_folio(folio, 0);
192-
for (i = 0; i < 2; i++) {
193-
/* maximum 3 bytes - due to match_root limitation */
194-
if (strncmp(dir_entry[i].de_fname, match_root[i], 3))
195-
error = 1;
196-
}
191+
if (memcmp(dir_entry[0].de_fname, ".", 2) ||
192+
memcmp(dir_entry[1].de_fname, "..", 3))
193+
error = 1;
197194
folio_release_kmap(folio, dir_entry);
198195
if (error)
199196
return "error reading root directory.";

0 commit comments

Comments
 (0)