This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] Replace the remaining uses of strerror with safe_strerror


On Fri, Dec 6, 2019 at 4:46 PM Pedro Alves <palves@redhat.com> wrote:
>
> 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 ...

Ah, great idea. That way I don't even need the #ifdef. Done, will send
a new version now.

Christian


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