Re: [PATCH] md/bcache: Mark __nonstring look-up table
Ard Biesheuvel <[email protected]>
| Newsgroups | org.kernel.vger.linux-bcache,org.kernel.vger.linux-hardening,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAMj1kXHfearSZG6TFTxxX87qmRkUmAefQm-TfPNS8j09kWxujQ@mail.gmail.com> |
On Thu, 17 Apr 2025 at 00:01, Kees Cook <[email protected]> wrote: > > GCC 15's new -Wunterminated-string-initialization notices that the 16 > character lookup table "zero_uuid" (which is not used as a C-String) > needs to be marked as "nonstring": > > drivers/md/bcache/super.c: In function 'uuid_find_empty': > drivers/md/bcache/super.c:549:43: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-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"; > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Add the annotation to silence the GCC warning. > > Signed-off-by: Kees Cook <[email protected]> > --- > Cc: Coly Li <[email protected]> > Cc: Kent Overstreet <[email protected]> > Cc: [email protected] > --- > drivers/md/bcache/super.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index e42f1400cea9..577d048170fe 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[] __nonstring = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; > Just static const char zero_uuid[16] = {}; should work fine here too. No need for the initializer. > return uuid_find(c, zero_uuid); > } > -- > 2.34.1 > >