Re: [PATCH v2 1/1] cachefiles: fix build with GCC 15
From: David Howells
Date: Mon Feb 10 2025 - 10:21:13 EST
Brahmajit Das <brahmajit.xyz@xxxxxxxxx> wrote:
> 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>
Acked-by: David Howells <dhowells@xxxxxxxxxx>