* [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15
@ 2025-04-15 11:14 Brahmajit Das
2025-04-16 10:41 ` kernel test robot
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Brahmajit Das @ 2025-04-15 11:14 UTC (permalink / raw)
Cc: Borislav Petkov (AMD), Dave Hansen, Pawan Gupta, Tony Luck,
linux-kernel
Since the Linux kernel initializes many non-C-string char arrays with
literals. While it would be possible to convert initializers from:
{ "BOOP", ... }
to something like:
{ { 'B', 'O', 'O', 'P' }, ... }
that is annoying.
Making -Wunterminated-string-initialization stay silent about char
arrays marked with nonstring would be much better.
Without the __attribute__((nonstring)) we would get the following build
error:
drivers/regulator/hi6421v530-regulator.c:189:19: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (21 chars into 20 available) [-Werror=unterminated-string-initialization]
189 | { .name = "hi6421v530-regulator" },
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Upstream GCC has added this commit
622968990beee7499e951590258363545b4a3b57[0][1] which silences warning
about truncating NUL char when initializing nonstring arrays.
[0]: https://gcc.gnu.org/cgit/gcc/commit/?id=622968990beee7499e951590258363545b4a3b57
[1]: https://gcc.gnu.org/cgit/gcc/commit/?id=afb46540d3921e96c4cd7ba8fa2c8b0901759455
Thanks to Jakub Jelinek <jakub@gcc.gnu.org> for the gcc patch.
Signed-off-by: Brahmajit Das <listout@listout.xyz>
---
include/linux/mod_devicetable.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index bd7e60c0b72f..f9bb623d0949 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -605,7 +605,7 @@ struct dmi_system_id {
#define PLATFORM_MODULE_PREFIX "platform:"
struct platform_device_id {
- char name[PLATFORM_NAME_SIZE];
+ char name[PLATFORM_NAME_SIZE] __attribute__((nonstring));
kernel_ulong_t driver_data;
};
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15
2025-04-15 11:14 [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15 Brahmajit Das
@ 2025-04-16 10:41 ` kernel test robot
2025-04-16 11:23 ` kernel test robot
2025-04-16 12:13 ` [PATCH v2 " Brahmajit Das
2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-04-16 10:41 UTC (permalink / raw)
To: Brahmajit Das
Cc: llvm, oe-kbuild-all, Borislav Petkov (AMD), Dave Hansen,
Pawan Gupta, Tony Luck, linux-kernel
Hi Brahmajit,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.15-rc2 next-20250416]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Brahmajit-Das/regulator-hi6421v530-fix-building-with-GCC-15/20250415-191555
base: linus/master
patch link: https://lore.kernel.org/r/20250415111411.6331-1-listout%40listout.xyz
patch subject: [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15
config: hexagon-randconfig-001-20250416 (https://download.01.org/0day-ci/archive/20250416/202504161823.huZUOtmg-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250416/202504161823.huZUOtmg-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504161823.huZUOtmg-lkp@intel.com/
All warnings (new ones prefixed by >>):
scripts/kernel-doc: 1: kernel-doc.py: not found
make[3]: *** [scripts/Makefile.build:203: scripts/mod/empty.o] Error 127 shuffle=4166761562
make[3]: *** Deleting file 'scripts/mod/empty.o'
In file included from scripts/mod/devicetable-offsets.c:3:
>> include/linux/mod_devicetable.h:608:47: warning: unknown attribute 'nonstring' ignored [-Wunknown-attributes]
608 | char name[PLATFORM_NAME_SIZE] __attribute__((nonstring));
| ^~~~~~~~~
1 warning generated.
make[3]: Target 'scripts/mod/' not remade because of errors.
make[2]: *** [Makefile:1279: prepare0] Error 2 shuffle=4166761562
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=4166761562
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2 shuffle=4166761562
make: Target 'prepare' not remade because of errors.
vim +/nonstring +608 include/linux/mod_devicetable.h
606
607 struct platform_device_id {
> 608 char name[PLATFORM_NAME_SIZE] __attribute__((nonstring));
609 kernel_ulong_t driver_data;
610 };
611
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15
2025-04-15 11:14 [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15 Brahmajit Das
2025-04-16 10:41 ` kernel test robot
@ 2025-04-16 11:23 ` kernel test robot
2025-04-16 12:13 ` [PATCH v2 " Brahmajit Das
2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-04-16 11:23 UTC (permalink / raw)
To: Brahmajit Das
Cc: oe-kbuild-all, Borislav Petkov (AMD), Dave Hansen, Pawan Gupta,
Tony Luck, linux-kernel
Hi Brahmajit,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.15-rc2 next-20250416]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Brahmajit-Das/regulator-hi6421v530-fix-building-with-GCC-15/20250415-191555
base: linus/master
patch link: https://lore.kernel.org/r/20250415111411.6331-1-listout%40listout.xyz
patch subject: [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15
config: arm-randconfig-002-20250416 (https://download.01.org/0day-ci/archive/20250416/202504161944.iNjyTvch-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250416/202504161944.iNjyTvch-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504161944.iNjyTvch-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from scripts/mod/devicetable-offsets.c:3:0:
>> include/linux/mod_devicetable.h:608:2: warning: 'nonstring' attribute directive ignored [-Wattributes]
char name[PLATFORM_NAME_SIZE] __attribute__((nonstring));
^~~~
scripts/kernel-doc: 1: kernel-doc.py: not found
make[3]: *** [scripts/Makefile.build:203: scripts/mod/empty.o] Error 127 shuffle=3373171021
make[3]: *** Deleting file 'scripts/mod/empty.o'
make[3]: Target 'scripts/mod/' not remade because of errors.
make[2]: *** [Makefile:1279: prepare0] Error 2 shuffle=3373171021
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=3373171021
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2 shuffle=3373171021
make: Target 'prepare' not remade because of errors.
vim +/nonstring +608 include/linux/mod_devicetable.h
606
607 struct platform_device_id {
> 608 char name[PLATFORM_NAME_SIZE] __attribute__((nonstring));
609 kernel_ulong_t driver_data;
610 };
611
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] regulator: hi6421v530: fix building with GCC 15
2025-04-15 11:14 [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15 Brahmajit Das
2025-04-16 10:41 ` kernel test robot
2025-04-16 11:23 ` kernel test robot
@ 2025-04-16 12:13 ` Brahmajit Das
2025-05-07 9:29 ` kernel test robot
2 siblings, 1 reply; 5+ messages in thread
From: Brahmajit Das @ 2025-04-16 12:13 UTC (permalink / raw)
To: brahmajit.xyz; +Cc: bp, dave.hansen, linux-kernel, pawan.kumar.gupta, tony.luck
Since the Linux kernel initializes many non-C-string char arrays with
literals. While it would be possible to convert initializers from:
{ "BOOP", ... }
to something like:
{ { 'B', 'O', 'O', 'P' }, ... }
that is annoying.
Making -Wunterminated-string-initialization stay silent about char
arrays marked with nonstring would be much better.
Without the __nonstring we would get the following build error:
drivers/regulator/hi6421v530-regulator.c:189:19: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (21 chars into 20 available) [-Werror=unterminated-string-initialization]
189 | { .name = "hi6421v530-regulator" },
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Upstream GCC has added this commit
622968990beee7499e951590258363545b4a3b57[0][1] which silences warning
about truncating NUL char when initializing nonstring arrays.
[0]: https://gcc.gnu.org/cgit/gcc/commit/?id=622968990beee7499e951590258363545b4a3b57
[1]: https://gcc.gnu.org/cgit/gcc/commit/?id=afb46540d3921e96c4cd7ba8fa2c8b0901759455
Thanks to Jakub Jelinek <jakub@gcc.gnu.org> for the gcc patch.
Signed-off-by: Brahmajit Das <listout@listout.xyz>
---
include/linux/mod_devicetable.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index bd7e60c0b72f..e3c9c427443d 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -605,7 +605,7 @@ struct dmi_system_id {
#define PLATFORM_MODULE_PREFIX "platform:"
struct platform_device_id {
- char name[PLATFORM_NAME_SIZE];
+ char name[PLATFORM_NAME_SIZE] __nonstring;
kernel_ulong_t driver_data;
};
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] regulator: hi6421v530: fix building with GCC 15
2025-04-16 12:13 ` [PATCH v2 " Brahmajit Das
@ 2025-05-07 9:29 ` kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2025-05-07 9:29 UTC (permalink / raw)
To: Brahmajit Das
Cc: oe-kbuild-all, bp, dave.hansen, linux-kernel, pawan.kumar.gupta,
tony.luck
Hi Brahmajit,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.15-rc5 next-20250506]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Brahmajit-Das/regulator-hi6421v530-fix-building-with-GCC-15/20250416-211351
base: linus/master
patch link: https://lore.kernel.org/r/20250416121305.13469-1-listout%40listout.xyz
patch subject: [PATCH v2 1/1] regulator: hi6421v530: fix building with GCC 15
config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20250507/202505071639.PQ4TVkSG-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250507/202505071639.PQ4TVkSG-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505071639.PQ4TVkSG-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from scripts/mod/file2alias.c:123:
>> scripts/mod/../../include/linux/mod_devicetable.h:608:39: error: expected ':', ',', ';', '}' or '__attribute__' before '__nonstring'
608 | char name[PLATFORM_NAME_SIZE] __nonstring;
| ^~~~~~~~~~~
scripts/mod/file2alias.c: In function 'do_platform_entry':
>> scripts/mod/file2alias.c:143:35: error: 'struct platform_device_id' has no member named 'name'
143 | typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f)
| ^~
scripts/mod/file2alias.c:932:9: note: in expansion of macro 'DEF_FIELD_ADDR'
932 | DEF_FIELD_ADDR(symval, platform_device_id, name);
| ^~~~~~~~~~~~~~
scripts/mod/../../include/linux/mod_devicetable.h:605:33: warning: format '%s' expects argument of type 'char *', but argument 4 has type 'int' [-Wformat=]
605 | #define PLATFORM_MODULE_PREFIX "platform:"
| ^~~~~~~~~~~
scripts/mod/file2alias.c:934:41: note: in expansion of macro 'PLATFORM_MODULE_PREFIX'
934 | module_alias_printf(mod, false, PLATFORM_MODULE_PREFIX "%s", *name);
| ^~~~~~~~~~~~~~~~~~~~~~
scripts/mod/file2alias.c:934:66: note: format string is defined here
934 | module_alias_printf(mod, false, PLATFORM_MODULE_PREFIX "%s", *name);
| ~^
| |
| char *
| %d
make[3]: *** [scripts/Makefile.host:131: scripts/mod/file2alias.o] Error 1
make[3]: Target 'scripts/mod/' not remade because of errors.
make[2]: *** [Makefile:1279: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +608 scripts/mod/../../include/linux/mod_devicetable.h
606
607 struct platform_device_id {
> 608 char name[PLATFORM_NAME_SIZE] __nonstring;
609 kernel_ulong_t driver_data;
610 };
611
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-07 9:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 11:14 [PATCH 1/1] regulator: hi6421v530: fix building with GCC 15 Brahmajit Das
2025-04-16 10:41 ` kernel test robot
2025-04-16 11:23 ` kernel test robot
2025-04-16 12:13 ` [PATCH v2 " Brahmajit Das
2025-05-07 9:29 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox