diff mbox series

ACPI: NFIT: fix flexible_array.cocci warnings

Message ID alpine.DEB.2.22.394.2012222207060.2723@hadrien (mailing list archive)
State New
Headers show
Series ACPI: NFIT: fix flexible_array.cocci warnings | expand

Commit Message

Julia Lawall Dec. 22, 2020, 9:09 p.m. UTC
From: kernel test robot <lkp@intel.com>

Zero-length and one-element arrays are deprecated, see
Documentation/process/deprecated.rst
Flexible-array members should be used instead.

Generated by: scripts/coccinelle/misc/flexible_array.cocci

Fixes: 7b36c1398fb6 ("coccinelle: misc: add flexible_array.cocci script")
CC: Denis Efremov <efremov@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   148842c98a24e508aecb929718818fbf4c2a6ff3
commit: 7b36c1398fb63f9c38cc83dc75f143d2e5995062 coccinelle: misc: add flexible_array.cocci script
:::::: branch date: 20 hours ago
:::::: commit date: 2 months ago

 core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dan Williams Dec. 24, 2020, 6:12 p.m. UTC | #1
On Tue, Dec 22, 2020 at 1:10 PM Julia Lawall <julia.lawall@inria.fr> wrote:
>
> From: kernel test robot <lkp@intel.com>
>
> Zero-length and one-element arrays are deprecated, see
> Documentation/process/deprecated.rst
> Flexible-array members should be used instead.
>
> Generated by: scripts/coccinelle/misc/flexible_array.cocci
>
> Fixes: 7b36c1398fb6 ("coccinelle: misc: add flexible_array.cocci script")
> CC: Denis Efremov <efremov@linux.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>

Hmm, this triggers:

drivers/acpi/nfit/core.c:2276:4: error: flexible array member in a
struct with no named members
drivers/acpi/nfit/core.c:2287:4: error: flexible array member in a
struct with no named members

$ gcc --version
gcc (GCC) 10.2.1 20201016 (Red Hat 10.2.1-6)

I'll need to circle back to this later.
diff mbox series

Patch

--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -2268,7 +2268,7 @@  struct nfit_set_info {
 		u64 region_offset;
 		u32 serial_number;
 		u32 pad;
-	} mapping[0];
+	} mapping[];
 };

 struct nfit_set_info2 {
@@ -2279,7 +2279,7 @@  struct nfit_set_info2 {
 		u16 manufacturing_date;
 		u8  manufacturing_location;
 		u8  reserved[31];
-	} mapping[0];
+	} mapping[];
 };

 static size_t sizeof_nfit_set_info(int num_mappings)