[PATCH] Fix readdir_r with long file names
Florian Weimer
fweimer@redhat.com
Tue Mar 8 12:20:00 GMT 2016
On 03/02/2016 06:44 PM, Paul Eggert wrote:
> +/* Declare a structure member named ID, with type "array of TYPE", and
> + with actual size unspecified but with nominal size SIZE for the
> + benefit of traditional applications. If the application is
> + compiled with _FLEXARRAY_SOURCE and if the compiler is C99 or
> + better, model this as a flexible array. Otherwise, model it as a
> + fixed-size array of size SIZE (followed by a flexible array
> + afterwards, if C99, for the benefit of source-code analyzers that
> + can use this as a cue that the array is really varying-size). The
> + fixed-size array is for compatibility with programs that unwisely
> + take the size of structures that contain flexible arrays, and which
> + rely on traditional glibc which uses fixed-size arrays. */
> +#ifndef __flexarray
> +# ifdef __USE_FLEXARRAY
> +# define __flexarray(id, type, size) type id[]
> +# else
> +# define __flexarray(id, type, size) type id[size]; type __flexarray __flexarr
> +# endif
> +#endif
Sorry, I'm not convinced this is good compiler hint. I suspect it moves
things in the opposite direction. Some compilers likely have hacks to
support arrays of length 1 as flexible arrays if the array is at the end
of a struct, and after your change, the member is no longer at the end,
potentially disabling the flexible array kludge.
I think we should interact better with compilers in this area, but this
needs fairly explicit mark-up, showing what we need, and not something
that requires the compiler to guess.
Thanks,
Florian
More information about the Libc-alpha
mailing list