summaryrefslogtreecommitdiffstats
path: root/stream/stream.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-26 21:21:56 +0100
committerwm4 <wm4@nowhere>2014-11-26 21:21:56 +0100
commitcc5437746312127aed4e4c8e62091707ec61153c (patch)
treedd0f5b575d3081d0057a0957ff3cb8556f817086 /stream/stream.c
parent3fe57e3cb691d75dc8813c29cada5e3ddfd2a295 (diff)
downloadmpv-cc5437746312127aed4e4c8e62091707ec61153c.tar.bz2
mpv-cc5437746312127aed4e4c8e62091707ec61153c.tar.xz
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.
Diffstat (limited to 'stream/stream.c')
-rw-r--r--stream/stream.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 2a851e82ec..4b161e6c1c 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -446,7 +446,7 @@ static void stream_capture_write(stream_t *s, void *buf, size_t len)
{
if (s->capture_file && len > 0) {
if (fwrite(buf, len, 1, s->capture_file) < 1) {
- MP_ERR(s, "Error writing capture file: %s\n", strerror(errno));
+ MP_ERR(s, "Error writing capture file: %s\n", mp_strerror(errno));
stream_set_capture_file(s, NULL);
}
}
@@ -467,7 +467,7 @@ void stream_set_capture_file(stream_t *s, const char *filename)
if (s->buf_pos < s->buf_len)
stream_capture_write(s, s->buffer, s->buf_len);
} else {
- MP_ERR(s, "Error opening capture file: %s\n", strerror(errno));
+ MP_ERR(s, "Error opening capture file: %s\n", mp_strerror(errno));
}
}
}