[PATCH v2 1/1] cachefiles: fix build with GCC 15
From: Brahmajit Das
Date: Wed Jan 22 2025 - 04:03:36 EST
Building with GCC 15 results in the following error
fs/cachefiles/key.c:12:9: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
12 | "0123456789" /* 0 - 9 */
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors
This due to GCC 15 having enabled -Wunterminated-string-initialization
by default[0]. Here we're increasing the size of cachefiles_charmap from
64 to 65 to ensure space for NUL. Unfortunately using
__attribute__((nonstring)) or converting to unsigned char [] didn't help
in this case (thanks to David Laight <david.laight.linux@xxxxxxxxx>).
Please also refer:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178, and
https://gcc.gnu.org/pipermail/gcc-patches/2024-December/671714.html
[0]:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-unterminated-string-initialization
Signed-off-by: Brahmajit Das <brahmajit.xyz@xxxxxxxxx>
---
fs/cachefiles/key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/cachefiles/key.c b/fs/cachefiles/key.c
index bf935e25bdbe..a75ea693f649 100644
--- a/fs/cachefiles/key.c
+++ b/fs/cachefiles/key.c
@@ -8,7 +8,7 @@
#include <linux/slab.h>
#include "internal.h"
-static const char cachefiles_charmap[64] =
+static const char cachefiles_charmap[65] =
"0123456789" /* 0 - 9 */
"abcdefghijklmnopqrstuvwxyz" /* 10 - 35 */
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 36 - 61 */
--
2.48.1