diff mbox series

[4/5] linux: Replace zero-length array with flexible-array member on struct dirstream

Message ID 20230621213444.2017-3-cristian@rodriguez.im
State New
Headers show
Series None | expand

Commit Message

Cristian Rodríguez June 21, 2023, 9:34 p.m. UTC
The linux kernel has always required a compiler supporting c99
flexible-arrays.

Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
 sysdeps/unix/sysv/linux/dirstream.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Weimer June 22, 2023, 5:25 a.m. UTC | #1
* Cristian Rodríguez via Libc-alpha:

> The linux kernel has always required a compiler supporting c99
> flexible-arrays.

This is not an installed header, so this commit message is misleading.
Why __attribute_nonstring__?

Thanks,
Florian
Cristian Rodríguez June 23, 2023, 3:56 p.m. UTC | #2
On Thu, Jun 22, 2023 at 1:25 AM Florian Weimer <fweimer@redhat.com> wrote:

> * Cristian Rodríguez via Libc-alpha:
>
> > The linux kernel has always required a compiler supporting c99
> > flexible-arrays.
>
> This is not an installed header, so this commit message is misleading.
> Why __attribute_nonstring__?
>
>
>
So there is a warning if someone, by a mistake obviously.,,treats it as an
string or calls any str* function on it.. data is filled with struct
linux_dirent  s
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/dirstream.h b/sysdeps/unix/sysv/linux/dirstream.h
index 3cb313b410..20ce7d1347 100644
--- a/sysdeps/unix/sysv/linux/dirstream.h
+++ b/sysdeps/unix/sysv/linux/dirstream.h
@@ -47,7 +47,7 @@  struct __dirstream
        sufficient because dirents on 32-bit platforms can require
        64-bit alignment.  We use "long double" here to be consistent
        with what malloc uses.  */
-    char data[0] __attribute__ ((aligned (__alignof__ (long double))));
+    char data[] __attribute_nonstring__ __attribute__ ((aligned (__alignof__ (long double))));
   };
 
 #define _DIR_dirfd(dirp)	((dirp)->fd)