[PATCH] Replace the remaining uses of strerror with safe_strerror
Pedro Alves
palves@redhat.com
Fri Dec 6 21:46:00 GMT 2019
On 12/6/19 8:36 PM, Christian Biesinger wrote:
> On Fri, Dec 6, 2019 at 2:06 PM Pedro Alves <palves@redhat.com> wrote:
>> GDBserver and (I assume) the IPA can be built with other C runtimes on Linux,
>> like musl and others. Do you know how musl behaves?
>
> Oof, looks like they return int :(
> http://git.musl-libc.org/cgit/musl/tree/src/string/strerror_r.c
>
> I guess I'll change to #if defined(IN_PROCESS_AGENT) && defined(__GLIBC__)?
>
Crazy thought --- use C++ overload resolution to pick the right thing
automatically:
/* Called if we have a XSI-compliant strerror_r. */
static char *select_strerror_r (int, char *buf) { return buf; }
/* Called if we have a GNU strerror_r. */
static char *select_strerror_r (char *res, char *) { return res; }
#ifdef IN_PROCESS_AGENT
return select_strerror_r (strerror_r (errnum, buf, buflen), buf);
#else ...
Thanks,
Pedro Alves
More information about the Gdb-patches
mailing list