[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250121080316.1273544-1-brahmajit.xyz@gmail.com>
Date: Tue, 21 Jan 2025 13:33:16 +0530
From: Brahmajit Das <brahmajit.xyz@...il.com>
To: dhowells@...hat.com,
djwong@...nel.org
Cc: netfs@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/1] netfs: fix building with GCC 15
While building with GCC 15 I noticed these build error
fs/netfs/fscache_cache.c:375:67: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
375 | static const char fscache_cache_states[NR__FSCACHE_CACHE_STATE] = "-PAEW";
| ^~~~~~~
cc1: all warnings being treated as errors
fs/netfs/fscache_cookie.c:32:69: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
32 | static const char fscache_cookie_states[FSCACHE_COOKIE_STATE__NR] = "-LCAIFUWRD";
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors
This due to GCC 15 having enabled -Wunterminated-string-initialization
by default[0].
Idea for this solution came from similar bug before where the
developer agreed to just increasing the array size by one[1].
[0]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-unterminated-string-initialization
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a500f3751d3c861be7e4463c933cf467240cca5d
Signed-off-by: Brahmajit Das <brahmajit.xyz@...il.com>
---
fs/netfs/fscache_cache.c | 2 +-
fs/netfs/fscache_cookie.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/netfs/fscache_cache.c b/fs/netfs/fscache_cache.c
index 9397ed39b0b4..2b554e1602a6 100644
--- a/fs/netfs/fscache_cache.c
+++ b/fs/netfs/fscache_cache.c
@@ -372,7 +372,7 @@ void fscache_withdraw_cache(struct fscache_cache *cache)
EXPORT_SYMBOL(fscache_withdraw_cache);
#ifdef CONFIG_PROC_FS
-static const char fscache_cache_states[NR__FSCACHE_CACHE_STATE] = "-PAEW";
+static const char fscache_cache_states[NR__FSCACHE_CACHE_STATE + 1] = "-PAEW";
/*
* Generate a list of caches in /proc/fs/fscache/caches
diff --git a/fs/netfs/fscache_cookie.c b/fs/netfs/fscache_cookie.c
index d4d4b3a8b106..bc0735c40ee7 100644
--- a/fs/netfs/fscache_cookie.c
+++ b/fs/netfs/fscache_cookie.c
@@ -29,7 +29,7 @@ static LIST_HEAD(fscache_cookie_lru);
static DEFINE_SPINLOCK(fscache_cookie_lru_lock);
DEFINE_TIMER(fscache_cookie_lru_timer, fscache_cookie_lru_timed_out);
static DECLARE_WORK(fscache_cookie_lru_work, fscache_cookie_lru_worker);
-static const char fscache_cookie_states[FSCACHE_COOKIE_STATE__NR] = "-LCAIFUWRD";
+static const char fscache_cookie_states[FSCACHE_COOKIE_STATE__NR + 1] = "-LCAIFUWRD";
static unsigned int fscache_lru_cookie_timeout = 10 * HZ;
void fscache_print_cookie(struct fscache_cookie *cookie, char prefix)
--
2.48.1
Powered by blists - more mailing lists