[PATCH] bcache: fix -Wunterminated-string-initialization from incoming gcc-15

Dmitry Antipov <[email protected]>
Newsgroups org.kernel.vger.linux-bcache
Message-ID <[email protected]>
When compiling with gcc version 15.0.0 20241204 (experimental),
I've noticed the following warning:

drivers/md/bcache/super.c: In function 'uuid_find_empty':
drivers/md/bcache/super.c:549:43: warning: initializer-string for array
of 'char' is too long [-Wunterminated-string-initialization]
  549 |         static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Since C string constants are null-byte terminated by default,
constant zero initializer of 'const char[16]' should have 15
bytes rather than 16.

Fixes: cafe56359144 ("bcache: A block layer cache")
Signed-off-by: Dmitry Antipov <[email protected]>

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index e7abfdd77c3b..c47a9ac031bd 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -546,7 +546,7 @@ static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
 
 static struct uuid_entry *uuid_find_empty(struct cache_set *c)
 {
-	static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+	static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
 
 	return uuid_find(c, zero_uuid);
 }
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.