[openwrt/openwrt] generic: power: backport v6.15 patch to fix build with GCC15
LEDE Commits
lede-commits at lists.infradead.org
Thu May 29 14:21:01 PDT 2025
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/7d064eef52ceec23535a45c6e06dff94b067ca05
commit 7d064eef52ceec23535a45c6e06dff94b067ca05
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Wed May 28 11:36:31 2025 +0000
generic: power: backport v6.15 patch to fix build with GCC15
Backports an upstream fix ([1]) for a build regression of
'drivers/power/supply' with GCC15 -Wunterminated-string-initialization.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=77f5bb150132bbbcd6bc37ffdc80c9e140e373a4
Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/18950
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
...e-nul-termination-to-fix-build-with-GCC15.patch | 39 ++++++++++++++++++++++
...e-nul-termination-to-fix-build-with-GCC15.patch | 39 ++++++++++++++++++++++
2 files changed, 78 insertions(+)
diff --git a/target/linux/generic/backport-6.12/807-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch b/target/linux/generic/backport-6.12/807-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch
new file mode 100644
index 0000000000..48f9c1c264
--- /dev/null
+++ b/target/linux/generic/backport-6.12/807-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch
@@ -0,0 +1,39 @@
+From 77f5bb150132bbbcd6bc37ffdc80c9e140e373a4 Mon Sep 17 00:00:00 2001
+From: Kees Cook <kees at kernel.org>
+Date: Wed, 16 Apr 2025 15:27:41 -0700
+Subject: [PATCH] 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 <kees at kernel.org>
+Link: https://lore.kernel.org/r/20250416222740.work.569-kees@kernel.org
+Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
+
+--- a/drivers/power/supply/power_supply_sysfs.c
++++ b/drivers/power/supply/power_supply_sysfs.c
+@@ -33,7 +33,7 @@ struct power_supply_attr {
+ [POWER_SUPPLY_PROP_ ## _name] = \
+ { \
+ .prop_name = #_name, \
+- .attr_name = #_name "\0", \
++ .attr_name = #_name, \
+ .text_values = _text, \
+ .text_values_len = _len, \
+ }
diff --git a/target/linux/generic/backport-6.6/807-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch b/target/linux/generic/backport-6.6/807-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch
new file mode 100644
index 0000000000..c462183853
--- /dev/null
+++ b/target/linux/generic/backport-6.6/807-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch
@@ -0,0 +1,39 @@
+From 77f5bb150132bbbcd6bc37ffdc80c9e140e373a4 Mon Sep 17 00:00:00 2001
+From: Kees Cook <kees at kernel.org>
+Date: Wed, 16 Apr 2025 15:27:41 -0700
+Subject: [PATCH] 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 <kees at kernel.org>
+Link: https://lore.kernel.org/r/20250416222740.work.569-kees@kernel.org
+Signed-off-by: Sebastian Reichel <sebastian.reichel at collabora.com>
+
+--- a/drivers/power/supply/power_supply_sysfs.c
++++ b/drivers/power/supply/power_supply_sysfs.c
+@@ -32,7 +32,7 @@ struct power_supply_attr {
+ [POWER_SUPPLY_PROP_ ## _name] = \
+ { \
+ .prop_name = #_name, \
+- .attr_name = #_name "\0", \
++ .attr_name = #_name, \
+ .text_values = _text, \
+ .text_values_len = _len, \
+ }
More information about the lede-commits
mailing list