[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

coping with conflicting strerror_r signatures [was: strerror vs. threads

From: Eric Blake
Subject: coping with conflicting strerror_r signatures [was: strerror vs. threads]
Date: Wed, 25 May 2011 09:28:16 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

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).


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   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]