Skip to content

Commit be913e7

Browse files
committed
gcc-15: get rid of misc extra NUL character padding
This removes two cases of explicit NUL padding that now causes warnings because of '-Wunterminated-string-initialization' being part of -Wextra in gcc-15. Gcc is being silly in this case when it says that it truncates a NUL terminator, because in these cases there were _multiple_ NUL characters. But we can get rid of the warning by just simplifying the two initializers that trigger the warning for me, so this does exactly that. I'm not sure why the power supply code did that odd .attr_name = #_name "\0", pattern: it was introduced in commit 2cabeaf ("power: supply: core: Cleanup power supply sysfs attribute list"), but that 'attr_name[]' field is an explicitly sized character array in a statically initialized variable, and a string initializer always has a terminating NUL _and_ statically initialized character arrays are zero-padded anyway, so it really seems to be rather extraneous belt-and-suspenders. The zero_uuid[16] initialization in drivers/md/bcache/super.c makes perfect sense, but it isn't necessary for the same reasons, and not worth the new gcc warning noise. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4b4bd8c commit be913e7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/md/bcache/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
546546

547547
static struct uuid_entry *uuid_find_empty(struct cache_set *c)
548548
{
549-
static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
549+
static const char zero_uuid[16] = { 0 };
550550

551551
return uuid_find(c, zero_uuid);
552552
}

drivers/power/supply/power_supply_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct power_supply_attr {
3333
[POWER_SUPPLY_PROP_ ## _name] = \
3434
{ \
3535
.prop_name = #_name, \
36-
.attr_name = #_name "\0", \
36+
.attr_name = #_name, \
3737
.text_values = _text, \
3838
.text_values_len = _len, \
3939
}

0 commit comments

Comments
 (0)