[PATCH] ipc/msg.c: Use C99 flexible array for mtext

From: Malkoot Khan
Date: Thu Dec 28 2023 - 13:09:03 EST


In the transition to C99 standards compliance, this patch replaces the
deprecated one-element array with a flexible array member. The C99 standard
introduces flexible array members for cases where the size of the array is
not known at compile time and can vary during runtime. The flexible array
'mtext[]' does not consume space in the structure itself; it's a marker for
the compiler to address variable length data directly following the struct
in memory. This approach is more aligned with modern C practices and
improves the maintainability of the kernel code.

Signed-off-by: Malkoot Khan <engr.mkhan1990@xxxxxxxxx>
---
ipc/msg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index fd08b3cb36d7..ee6af4fe52bf 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -978,7 +978,7 @@ SYSCALL_DEFINE4(msgsnd, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,

struct compat_msgbuf {
compat_long_t mtype;
- char mtext[1];
+ char mtext[];
};

long compat_ksys_msgsnd(int msqid, compat_uptr_t msgp,
--
2.34.1