On 05/25/2011 08:32 AM, Eric Blake wrote:
> If glibc were to change GNU strerror_r to _always_ populate buf, in
> addition to the return string, then you could blindly call either
> variant of strerror_r and just ignore the return value; the only
> remaining problem is making sure you provide a large enough buffer for
> any resulting string, since you no longer have error checking to tell if
> buf got truncated.  I guess it's worth a shot asking Uli if he'll make
> that change in glibc (since he already changed __xpg_strerror_r to
> populate buf).

http://sourceware.org/bugzilla/show_bug.cgi?id=12805

If Uli agrees to fix it in glibc.git, then we are that much closer to
having a strerror_r-gnu that guarantees that buf is always populated (by
replacing strerror_r on older glibc), at which point it no longer
matters which return type is in effect.  That gets us closer to the idea
of requiring that a strerror_r be present, but we don't care if it is
strerror_r-posix or strerror_r-gnu.  At which point, I could see doing
the following:

perror depends on strerror_r-posix, but ignores the return type, so that
it also works with strerror_r-gnu (more generally, any gnulib code that
depends on error strings would be written to depend on strerror_r-posix,
but to also work if strerror_r-gnu is in use)

strerror_r-gnu depends on and overrides strerror_r-posix to guarantee
the GNU return type; without it, you are left with the POSIX signature.
 While gnulib code can't depend on the return type, your application
can, because you know which of the two modules you imported.
Additionally, the strerror_r-gnu module would expose __xpg_strerror_r on
all platforms (not just glibc and cygwin), to make it possible to still
get at the POSIX signature, although we might go with the nicer name
xpg_strerror_r (no leading underscores).

test-strerror_r checks C witness macros to see which signature is in
effect, in order to determine which aspects of the return type to check.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to