This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] glob: Avoid copying the d_name field of struct dirent [BZ #19779]


> +# if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
> +  __typeof__ (((struct dirent) {}).d_type) type;
> +# endif

__typeof__ isn't portable to non-GCC compilers. How about if we just declare d_type to be 'unsigned char'? That should be portable enough in practice.


> +# if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
> +/* Designated initializer based on the d_type member of struct
> +   dirent.  */
> +#  define D_TYPE_TO_RESULT(source) .type = (source)->d_type

Gnulib still ports to C89, which makes compound literals dicey. We've been thinking of upping that to C99 so this is not an insurmountable obstacle (so long as the code sticks to C99-compatible compound literals, which I think it does). Still, this macro and its relatives are a bit tricky, and if we're going to use tricky macros anyway perhaps we'd be better off having them expand to C89 as that shouldn't make things much more obscure.


> +/* True if the directory entry D might be a symbolic link.  */
> +static inline bool

In Gnulib we typically prefer to say just 'static' without the clutter of 'inline', for the same reason we typically don't bother with the clutter of 'register'.


> +# define GL_READDIR(pglob, stream) (pglob)->gl_readdir ((stream))

No need for double parenthesization.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]