]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
disk-utils: add attribute nonstring to bfs byte arrays
authorCristian Rodríguez <cristian@rodriguez.im>
Tue, 8 Apr 2025 13:41:36 +0000 (09:41 -0400)
committerCristian Rodríguez <cristian@rodriguez.im>
Tue, 8 Apr 2025 13:41:36 +0000 (09:41 -0400)
GCC15 requires to annotate such fields as nonstrings or a warning
is now issued that they are missing the ending null.

disk-utils/mkfs.bfs.c
include/c.h

index d18589ab288f6f7d7ff095226d89f811001a5ab6..30c28d9e7ee9ce94dc2429a8ba46f96e773ed3bd 100644 (file)
@@ -48,8 +48,8 @@ struct bfssb {
        int32_t s_backup_from, s_backup_to;
 
        /* labels - may well contain garbage */
-       char s_fsname[6];
-       char s_volume[6];
+       char s_fsname[6] __ul_nonstring;
+       char s_volume[6] __ul_nonstring;
        char s_pad[472];
 };
 
index e0148e019c5e81aa1d7bb9282af56dd23480d8c1..50e34a120f925530a7ddd1ff1654a482677c1698 100644 (file)
@@ -153,6 +153,12 @@ C23   : https://en.cppreference.com/w/c/language/attributes/fallthrough
 # define __ul_returns_nonnull
 #endif
 
+#if __has_attribute(__nonstring__)
+# define __ul_nonstring __attribute__((__nonstring__))
+#else
+# define __ul_nonstring
+#endif
+
 /*
  * Force a compilation error if condition is true, but also produce a
  * result (of value 0 and type size_t), so the expression can be used