* drivers/parport/procfs.c:267:18-28: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays) (fwd)
@ 2024-11-02 21:05 Julia Lawall
2024-11-19 10:29 ` Joel Granados
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2024-11-02 21:05 UTC (permalink / raw)
To: Joel Granados; +Cc: Luis Chamberlain, linux-kernel, oe-kbuild-all
If device_dir is meant to be a flexible array, use [] instead or [1].
julia
---------- Forwarded message ----------
Date: Sun, 3 Nov 2024 04:56:55 +0800
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
Subject: drivers/parport/procfs.c:267:18-28: WARNING use flexible-array member
instead
(https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-
and-one-element-arrays)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Joel Granados <j.granados@samsung.com>
CC: Luis Chamberlain <mcgrof@kernel.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 11066801dd4b7c4d75fce65c812723a80c1481ae
commit: 0829381e481ab2760086cc88090f70e761e4fcc2 parport: Remove the now superfluous sentinel element from ctl_table array
date: 1 year, 1 month ago
:::::: branch date: 19 hours ago
:::::: commit date: 1 year, 1 month ago
config: x86_64-randconfig-102-20241102 (https://download.01.org/0day-ci/archive/20241103/202411030437.OYnKHsPA-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
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>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202411030437.OYnKHsPA-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> drivers/parport/procfs.c:267:18-28: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
drivers/parport/procfs.c:364:18-28: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
vim +267 drivers/parport/procfs.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 257
^1da177e4c3f41 Linus Torvalds 2005-04-16 258
^1da177e4c3f41 Linus Torvalds 2005-04-16 259 struct parport_sysctl_table {
37e9981e33e4d3 Joel Granados 2023-06-16 260 struct ctl_table_header *port_header;
37e9981e33e4d3 Joel Granados 2023-06-16 261 struct ctl_table_header *devices_header;
0829381e481ab2 Joel Granados 2023-10-02 262 #ifdef CONFIG_PARPORT_1284
0829381e481ab2 Joel Granados 2023-10-02 263 struct ctl_table vars[10];
0829381e481ab2 Joel Granados 2023-10-02 264 #else
0829381e481ab2 Joel Granados 2023-10-02 265 struct ctl_table vars[5];
0829381e481ab2 Joel Granados 2023-10-02 266 #endif /* IEEE 1284 support */
0829381e481ab2 Joel Granados 2023-10-02 @267 struct ctl_table device_dir[1];
^1da177e4c3f41 Linus Torvalds 2005-04-16 268 };
^1da177e4c3f41 Linus Torvalds 2005-04-16 269
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: drivers/parport/procfs.c:267:18-28: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays) (fwd)
2024-11-02 21:05 drivers/parport/procfs.c:267:18-28: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays) (fwd) Julia Lawall
@ 2024-11-19 10:29 ` Joel Granados
0 siblings, 0 replies; 2+ messages in thread
From: Joel Granados @ 2024-11-19 10:29 UTC (permalink / raw)
To: Julia Lawall
Cc: Joel Granados, Luis Chamberlain, linux-kernel, oe-kbuild-all,
Sudip Mukherjee, Sudip Mukherjee
On Sat, Nov 02, 2024 at 10:05:24PM +0100, Julia Lawall wrote:
> If device_dir is meant to be a flexible array, use [] instead or [1].
I don't think it is meant as a flexible array. I'll try to contextualize what is
happening and suggest a way forward.
>
> julia
>
> ---------- Forwarded message ----------
> Date: Sun, 3 Nov 2024 04:56:55 +0800
> From: kernel test robot <lkp@intel.com>
> To: oe-kbuild@lists.linux.dev
> Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
...
> vim +267 drivers/parport/procfs.c
>
> ^1da177e4c3f41 Linus Torvalds 2005-04-16 257
> ^1da177e4c3f41 Linus Torvalds 2005-04-16 258
> ^1da177e4c3f41 Linus Torvalds 2005-04-16 259 struct parport_sysctl_table {
> 37e9981e33e4d3 Joel Granados 2023-06-16 260 struct ctl_table_header *port_header;
> 37e9981e33e4d3 Joel Granados 2023-06-16 261 struct ctl_table_header *devices_header;
> 0829381e481ab2 Joel Granados 2023-10-02 262 #ifdef CONFIG_PARPORT_1284
> 0829381e481ab2 Joel Granados 2023-10-02 263 struct ctl_table vars[10];
> 0829381e481ab2 Joel Granados 2023-10-02 264 #else
> 0829381e481ab2 Joel Granados 2023-10-02 265 struct ctl_table vars[5];
> 0829381e481ab2 Joel Granados 2023-10-02 266 #endif /* IEEE 1284 support */
> 0829381e481ab2 Joel Granados 2023-10-02 @267 struct ctl_table device_dir[1];
> ^1da177e4c3f41 Linus Torvalds 2005-04-16 268 };
> ^1da177e4c3f41 Linus Torvalds 2005-04-16 269
What we were doing was just to remove the sentinel from that device_dir array.
As you can it was originally sized at 2 (with the second element left empty to
signify a sentinel). This is the diff:
``` diff
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 4e5b972c3e26..532d5cbbd344 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -259,8 +259,12 @@ PARPORT_MAX_SPINTIME_VALUE;
struct parport_sysctl_table {
struct ctl_table_header *port_header;
struct ctl_table_header *devices_header;
- struct ctl_table vars[12];
- struct ctl_table device_dir[2];
+#ifdef CONFIG_PARPORT_1284
+ struct ctl_table vars[10];
+#else
+ struct ctl_table vars[5];
+#endif /* IEEE 1284 support */
+ struct ctl_table device_dir[1];
};
```
So the array was at the end with a size to begin with. But I don't think that
its original intention was to be a flexible array. I'm not sure though, I'm
ccing the parport maintainers in hope that they can shed more light on this.
Notice that I prefer device_dir to be an array, so it can be passed to the
sysctl register call as is
Best
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
--
Joel Granados
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-19 10:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02 21:05 drivers/parport/procfs.c:267:18-28: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays) (fwd) Julia Lawall
2024-11-19 10:29 ` Joel Granados
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox