Commit 4ec6dd2c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use %m on GLIBC to work-around strerror_r prototype problems

parent e0c9e748
...@@ -95,23 +95,35 @@ static inline unsigned long vlc_threadid (void) ...@@ -95,23 +95,35 @@ static inline unsigned long vlc_threadid (void)
void vlc_pthread_fatal (const char *action, int error, void vlc_pthread_fatal (const char *action, int error,
const char *file, unsigned line) const char *file, unsigned line)
{ {
char buf[1000];
const char *msg;
fprintf (stderr, "LibVLC fatal error %s in thread %lu at %s:%u: %d\n", fprintf (stderr, "LibVLC fatal error %s in thread %lu at %s:%u: %d\n",
action, vlc_threadid (), file, line, error); action, vlc_threadid (), file, line, error);
fflush (stderr); fflush (stderr);
/* Sometimes strerror_r() crashes too, so make sure we print an error /* Sometimes strerror_r() crashes too, so make sure we print an error
* message before we invoke it */ * message before we invoke it */
#ifdef __GLIBC__ && _POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600 && _GNU_SOURCE #ifdef __GLIBC__
/* use GNU prototype */ /* Avoid the strerror_r() prototype brain damage in glibc */
msg = strerror_r (error, buf, sizeof (buf)); errno = error;
fprintf (stderr, " Error message: %m\n");
#else #else
msg = buf; char buf[1000];
if (!strerror_r (error, buf, sizeof (buf))) const char *msg;
switch (sterror_r (error, buf, sizeof (buf)))
{
case 0:
msg = buf;
break;
case ERANGE: /* should never happen */
msg = "unknwon (too big to display)";
break;
default:
msg = "unknown (invalid error number)";
break;
}
fprintf (stderr, " Error message: %s\n", msg);
#endif #endif
fprintf (stderr, "Error description: \"%s\"\n", msg ? msg : "(null)");
fflush (stderr); fflush (stderr);
abort (); abort ();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment