[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stdio: don't require ignore_value around fwrite
From: |
Bruno Haible |
Subject: |
Re: stdio: don't require ignore_value around fwrite |
Date: |
Sun, 20 Mar 2011 21:58:46 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Paul,
> + This patch works around libc bug 11959
> + <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>.
This glibc bug is in status "NEW". I think before adding a workaround in
gnulib, the first action should be to ping the glibc maintainers about it.
If they close it as rejected / invalid / won't fix, then IMO we can consider
to do something in gnulib about it.
Three technical points about the patch:
- For legibility,
> +#if (0 < __USE_FORTIFY_LEVEL \
> + && ! (@GNULIB_FWRITE@ \
> + && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@))
> +# define GNULIB_inline_rpl_fwrite 1
> +static inline size_t _GL_ARG_NONNULL ((1, 4))
> +rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
> +{
> + size_t r = fwrite (ptr, s, n, stream);
> + (void) r;
> + return r;
> +}
> +#endif
>
> -#if @GNULIB_FWRITE@
> -# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
> +#if @GNULIB_FWRITE@ || GNULIB_inline_rpl_fwrite
> +# if ((@REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) \
could you please keep both parts in a single
#if @GNULIB_FWRITE@
#endif
block?
Since GNULIB_FWRITE is always 1 in practice (see m4/stdio_h.m4), you don't
need to care about the case when GNULIB_FWRITE is 0.
- The workaround ought also to be documented in doc/posix-functions/fwrite.texi.
- You ask:
> However, I'm no expert with C++ and the C++ parts of it
> need another pair of eyes to look at.
You can test C++ compatibility by doing
$ ./gnulib-tool --test --with-tests --with-c++-tests stdio
But I can tell you in advance that the C++ idioms just don't work with
'static inline' replacements, as seen in
<http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00128.html>.
The workaround is to provide the wrapper function in lib/stdio-write.c
instead of as an inline function.
Bruno
--
In memoriam Jan Nepomucký <http://en.wikipedia.org/wiki/John_of_Nepomuk>