* [PATCH 2/5] include: Replace zero-length array "msg" with C99 flexible-array.
@ 2023-06-21 21:34 Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Cristian Rodríguez
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-21 21:34 UTC (permalink / raw)
To: libc-alpha; +Cc: Cristian Rodríguez
Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
include/stdlib.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/stdlib.h b/include/stdlib.h
index 7deb8193d7..206ceb7435 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -360,7 +360,7 @@ libc_hidden_proto (__qfcvt_r)
struct abort_msg_s
{
unsigned int size;
- char msg[0];
+ char msg[];
};
extern struct abort_msg_s *__abort_msg;
libc_hidden_proto (__abort_msg)
--
2.41.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct
2023-06-21 21:34 [PATCH 2/5] include: Replace zero-length array "msg" with C99 flexible-array Cristian Rodríguez
@ 2023-06-21 21:34 ` Cristian Rodríguez
2023-06-21 21:44 ` Cristian Rodríguez
2023-06-22 5:23 ` Florian Weimer
2023-06-21 21:34 ` [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 5/5] stdio-common: Replace zero-length array with flexible-array member Cristian Rodríguez
2 siblings, 2 replies; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-21 21:34 UTC (permalink / raw)
To: libc-alpha; +Cc: Cristian Rodríguez
Current kernel versions require a compiler supporting -std=gnu11
and therefore supporting C99 flexible arrays. old versions require
a c89 compiler supporting this feature as an extension.
Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
sysdeps/unix/sysv/linux/sys/inotify.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h b/sysdeps/unix/sysv/linux/sys/inotify.h
index 1e8e68cd97..535f57e27b 100644
--- a/sysdeps/unix/sysv/linux/sys/inotify.h
+++ b/sysdeps/unix/sysv/linux/sys/inotify.h
@@ -31,7 +31,7 @@ struct inotify_event
uint32_t mask; /* Watch mask. */
uint32_t cookie; /* Cookie to synchronize two events. */
uint32_t len; /* Length (including NULs) of name. */
- char name __flexarr; /* Name. */
+ char name[]; /* Name. */
};
--
2.41.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream
2023-06-21 21:34 [PATCH 2/5] include: Replace zero-length array "msg" with C99 flexible-array Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Cristian Rodríguez
@ 2023-06-21 21:34 ` Cristian Rodríguez
2023-06-22 5:25 ` Florian Weimer
2023-06-21 21:34 ` [PATCH 5/5] stdio-common: Replace zero-length array with flexible-array member Cristian Rodríguez
2 siblings, 1 reply; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-21 21:34 UTC (permalink / raw)
To: libc-alpha; +Cc: Cristian Rodríguez
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(-)
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)
--
2.41.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/5] stdio-common: Replace zero-length array with flexible-array member
2023-06-21 21:34 [PATCH 2/5] include: Replace zero-length array "msg" with C99 flexible-array Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream Cristian Rodríguez
@ 2023-06-21 21:34 ` Cristian Rodríguez
2 siblings, 0 replies; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-21 21:34 UTC (permalink / raw)
To: libc-alpha; +Cc: Cristian Rodríguez
Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
stdio-common/reg-modifier.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/stdio-common/reg-modifier.c b/stdio-common/reg-modifier.c
index a52022d1ba..d957d85a5f 100644
--- a/stdio-common/reg-modifier.c
+++ b/stdio-common/reg-modifier.c
@@ -27,7 +27,7 @@ struct printf_modifier_record
{
struct printf_modifier_record *next;
int bit;
- wchar_t str[0];
+ wchar_t str[];
};
struct printf_modifier_record **__printf_modifier_table attribute_hidden;
--
2.41.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct
2023-06-21 21:34 ` [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Cristian Rodríguez
@ 2023-06-21 21:44 ` Cristian Rodríguez
2023-06-22 5:23 ` Florian Weimer
1 sibling, 0 replies; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-21 21:44 UTC (permalink / raw)
To: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]
This patch only syncs with the current kernel headers.
On Wed, Jun 21, 2023 at 5:35 PM Cristian Rodríguez <cristian@rodriguez.im>
wrote:
> Current kernel versions require a compiler supporting -std=gnu11
> and therefore supporting C99 flexible arrays. old versions require
> a c89 compiler supporting this feature as an extension.
>
> Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
> ---
> sysdeps/unix/sysv/linux/sys/inotify.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h
> b/sysdeps/unix/sysv/linux/sys/inotify.h
> index 1e8e68cd97..535f57e27b 100644
> --- a/sysdeps/unix/sysv/linux/sys/inotify.h
> +++ b/sysdeps/unix/sysv/linux/sys/inotify.h
> @@ -31,7 +31,7 @@ struct inotify_event
> uint32_t mask; /* Watch mask. */
> uint32_t cookie; /* Cookie to synchronize two events. */
> uint32_t len; /* Length (including NULs) of name. */
> - char name __flexarr; /* Name. */
> + char name[]; /* Name. */
> };
>
>
> --
> 2.41.0
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct
2023-06-21 21:34 ` [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Cristian Rodríguez
2023-06-21 21:44 ` Cristian Rodríguez
@ 2023-06-22 5:23 ` Florian Weimer
2023-06-23 15:57 ` Cristian Rodríguez
1 sibling, 1 reply; 9+ messages in thread
From: Florian Weimer @ 2023-06-22 5:23 UTC (permalink / raw)
To: Cristian Rodríguez via Libc-alpha; +Cc: Cristian Rodríguez
* Cristian Rodríguez via Libc-alpha:
> Current kernel versions require a compiler supporting -std=gnu11
> and therefore supporting C99 flexible arrays. old versions require
> a c89 compiler supporting this feature as an extension.
Ugh, you are right:
commit 94dfc73e7cf4a31da66b8843f0b9283ddd6b8381
Author: Gustavo A. R. Silva <gustavoars@kernel.org>
Date: Wed Apr 6 19:36:51 2022 -0500
treewide: uapi: Replace zero-length arrays with flexible-array members
It's specifically targeting UAPI headers, so it's not a (harmless)
kernel-internal change.
Do you know if anyone has looked at the compatibility impact of this
change on C parsers? I'm not sure if we can do the same thing. In
particular, if kernel headers are not C89-compatible, we may have to add
kludges to our own headers that avoid including them in C89 mode.
Thanks,
Florian
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream
2023-06-21 21:34 ` [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream Cristian Rodríguez
@ 2023-06-22 5:25 ` Florian Weimer
2023-06-23 15:56 ` Cristian Rodríguez
0 siblings, 1 reply; 9+ messages in thread
From: Florian Weimer @ 2023-06-22 5:25 UTC (permalink / raw)
To: Cristian Rodríguez via Libc-alpha; +Cc: Cristian Rodríguez
* 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream
2023-06-22 5:25 ` Florian Weimer
@ 2023-06-23 15:56 ` Cristian Rodríguez
0 siblings, 0 replies; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-23 15:56 UTC (permalink / raw)
To: Florian Weimer; +Cc: Cristian Rodríguez via Libc-alpha
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct
2023-06-22 5:23 ` Florian Weimer
@ 2023-06-23 15:57 ` Cristian Rodríguez
0 siblings, 0 replies; 9+ messages in thread
From: Cristian Rodríguez @ 2023-06-23 15:57 UTC (permalink / raw)
To: Florian Weimer; +Cc: Cristian Rodríguez via Libc-alpha
[-- Attachment #1: Type: text/plain, Size: 638 bytes --]
On Thu, Jun 22, 2023 at 1:23 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> Do you know if anyone has looked at the compatibility impact of this
> change on C parsers? I'm not sure if we can do the same thing. In
> particular, if kernel headers are not C89-compatible, we may have to add
> kludges to our own headers that avoid including them in C89 mode.
>
>
>
On this case it is a linux feature, which has required this as an
extension, probably since forever. I have only checked kernel 3.2 as the
minimum and that version indeed uses c99 flex arrays at least *internally*
(I have not checked all headers though)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-06-23 15:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-21 21:34 [PATCH 2/5] include: Replace zero-length array "msg" with C99 flexible-array Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 3/5] linux: Replace zero-length array with flexible-array member on inotify struct Cristian Rodríguez
2023-06-21 21:44 ` Cristian Rodríguez
2023-06-22 5:23 ` Florian Weimer
2023-06-23 15:57 ` Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 4/5] linux: Replace zero-length array with flexible-array member on struct dirstream Cristian Rodríguez
2023-06-22 5:25 ` Florian Weimer
2023-06-23 15:56 ` Cristian Rodríguez
2023-06-21 21:34 ` [PATCH 5/5] stdio-common: Replace zero-length array with flexible-array member Cristian Rodríguez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).