[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250121221911.424a2003@pumpkin>
Date: Tue, 21 Jan 2025 22:19:11 +0000
From: David Laight <david.laight.linux@...il.com>
To: Brahmajit Das <brahmajit.xyz@...il.com>
Cc: dhowells@...hat.com, netfs@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] cachefiles: fix build with GCC 15
On Tue, 21 Jan 2025 14:45:30 +0530
Brahmajit Das <brahmajit.xyz@...il.com> wrote:
> While building with GCC 15 I noticed these build 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]. Separating each characters to ensure NUL termination of
> char array.
>
> [0]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-unterminated-string-initialization
>
> Signed-off-by: Brahmajit Das <brahmajit.xyz@...il.com>
> ---
> fs/cachefiles/key.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/fs/cachefiles/key.c b/fs/cachefiles/key.c
> index bf935e25bdbe..555a0ec9eff4 100644
> --- a/fs/cachefiles/key.c
> +++ b/fs/cachefiles/key.c
> @@ -8,12 +8,14 @@
> #include <linux/slab.h>
> #include "internal.h"
>
> -static const char cachefiles_charmap[64] =
> - "0123456789" /* 0 - 9 */
> - "abcdefghijklmnopqrstuvwxyz" /* 10 - 35 */
> - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 36 - 61 */
> - "_-" /* 62 - 63 */
> - ;
> +static const char cachefiles_charmap[64] = {
> + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', /* 0 - 9 */
> + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', /* 10 - 35 */
> + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', /* 10 - 35 */
> + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', /* 36 - 61 */
> + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', /* 36 - 61 */
> + '_', '-' /* 62 - 63 */
> +};
That is just horrid.
I think there is a attribute that stops the warning.
Or just convert to unsigned char [].
David
>
> static const char cachefiles_filecharmap[256] = {
> /* we skip space and tab and control chars */
Powered by blists - more mailing lists