diff mbox series

[Unstable/N] UBUNTU: SAUCE: modpost: Replace 0-length array with flex-array member

Message ID 20240222184500.876596-1-juerg.haefliger@canonical.com
State New
Headers show
Series [Unstable/N] UBUNTU: SAUCE: modpost: Replace 0-length array with flex-array member | expand

Commit Message

Juerg Haefliger Feb. 22, 2024, 6:45 p.m. UTC
Fake flexible arrays (zero-length and one-element arrays) are deprecated,
and should be replaced by flexible-array members. This fixes the following
compiler warning:

 CC      kernel/module/version.o
../kernel/module/version.c: In function 'check_version':
../kernel/module/version.c:37:21: warning: 'strcmp' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
   37 |                 if (strcmp(versions->name, symname) != 0)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../kernel/module/version.c:8:
../include/linux/module.h:41:14: note: source object 'name' of size 0
   41 |         char name[0];
      |              ^~~~

Fixes: 08bc01030daa ("UBUNTU: SAUCE: modpost: support arbitrary symbol length in modversion")
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
---
 include/linux/module.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrea Righi Feb. 22, 2024, 7:57 p.m. UTC | #1
On Thu, Feb 22, 2024 at 07:45:00PM +0100, Juerg Haefliger wrote:
> Fake flexible arrays (zero-length and one-element arrays) are deprecated,
> and should be replaced by flexible-array members. This fixes the following
> compiler warning:
> 
>  CC      kernel/module/version.o
> ../kernel/module/version.c: In function 'check_version':
> ../kernel/module/version.c:37:21: warning: 'strcmp' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
>    37 |                 if (strcmp(versions->name, symname) != 0)
>       |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from ../kernel/module/version.c:8:
> ../include/linux/module.h:41:14: note: source object 'name' of size 0
>    41 |         char name[0];
>       |              ^~~~
> 
> Fixes: 08bc01030daa ("UBUNTU: SAUCE: modpost: support arbitrary symbol length in modversion")
> Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>

Applied to noble/linux and noble/linux-unstable.

Thanks!
-Andrea
diff mbox series

Patch

diff --git a/include/linux/module.h b/include/linux/module.h
index 20b1e8429656..382f2d73afa9 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -38,7 +38,7 @@  struct modversion_info {
 	/* Offset of the next modversion entry in relation to this one. */
 	u32 next;
 	u32 crc;
-	char name[0];
+	char name[]; /* Flexible array member */
 } __packed;
 
 struct module;