From: David Laight <david.laight.linux@gmail.com>
To: Brahmajit Das <brahmajit.xyz@gmail.com>
Cc: dhowells@redhat.com, netfs@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] cachefiles: fix build with GCC 15
Date: Tue, 21 Jan 2025 22:19:11 +0000 [thread overview]
Message-ID: <20250121221911.424a2003@pumpkin> (raw)
In-Reply-To: <20250121091530.1316673-1-brahmajit.xyz@gmail.com>
On Tue, 21 Jan 2025 14:45:30 +0530
Brahmajit Das <brahmajit.xyz@gmail.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@gmail.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 */
next prev parent reply other threads:[~2025-01-21 22:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 9:15 [PATCH 1/1] cachefiles: fix build with GCC 15 Brahmajit Das
2025-01-21 22:19 ` David Laight [this message]
2025-01-21 22:41 ` David Laight
2025-01-22 9:03 ` [PATCH v2 " Brahmajit Das
2025-02-10 15:20 ` David Howells
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=20250121221911.424a2003@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=brahmajit.xyz@gmail.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netfs@lists.linux.dev \
/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