From cc5437746312127aed4e4c8e62091707ec61153c Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 26 Nov 2014 21:21:56 +0100 Subject: Do not call strerror() ...because everything is terrible. strerror() is not documented as having to be thread-safe by POSIX and C11. (Which is pretty much bullshit, because both mandate threads and some form of thread-local storage - so there's no excuse why implementation couldn't implement this in a thread-safe way. Especially with C11 this is ridiculous, because there is no way to use threads and convert error numbers to strings at the same time!) Since we heavily use threads now, we should avoid unsafe functions like strerror(). strerror_r() is in POSIX, but GNU/glibc deliberately fucks it up and gives the function different semantics than the POSIX one. It's a bit of work to convince this piece of shit to expose the POSIX standard function, and not the messed up GNU one. strerror_l() is also in POSIX, but only since the 2008 standard, and thus is not widespread. The solution is using avlibc (libavutil, by its official name), which handles the unportable details for us, mostly. We avoid some pain. --- stream/stream_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'stream/stream_file.c') diff --git a/stream/stream_file.c b/stream/stream_file.c index eef0dcc5cc..a78cda1f89 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -29,6 +29,7 @@ #include "osdep/io.h" +#include "common/common.h" #include "common/msg.h" #include "stream.h" #include "options/m_option.h" @@ -253,7 +254,7 @@ static int open_f(stream_t *stream) fd = open(filename, m | O_BINARY, openmode); if (fd < 0) { MP_ERR(stream, "Cannot open file '%s': %s\n", - filename, strerror(errno)); + filename, mp_strerror(errno)); return STREAM_ERROR; } struct stat st; -- cgit v1.2.3