Skip to content

Commit 77f5bb1

Browse files
keessre
authored andcommitted
power: supply: sysfs: Remove duplicate NUL termination
GCC 15's new -Wunterminated-string-initialization notices that one of the sysfs attr strings would lack the implicit trailing NUL byte during initialization: drivers/power/supply/power_supply_sysfs.c:183:57: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (32 chars into 31 available) [-Wunterminated-string-initialization] 183 | POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD), | ^ drivers/power/supply/power_supply_sysfs.c:36:23: note: in definition of macro '_POWER_SUPPLY_ATTR' 36 | .attr_name = #_name "\0", \ | ^~~~~ drivers/power/supply/power_supply_sysfs.c:183:9: note: in expansion of macro 'POWER_SUPPLY_ATTR' 183 | POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD), | ^~~~~~~~~~~~~~~~~ However, the macro used was explicitly adding a trailing NUL byte (which is not needed). Remove this to avoid the GCC warning. No binary differences are seen after this change (there was always run for a NUL byte, it's just that the _second_ NUL byte was getting truncated). Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 4e55fb7 commit 77f5bb1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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)