diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-25 13:48:56 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-25 13:48:56 +0200 |
commit | e7513e1286ca1b747485f950b0e1c93612b6736c (patch) | |
tree | 5b203532f1a3a08bab66fd81d17e8fa7d1f0d383 /libavformat/libsmbclient.c | |
parent | af03ba9aa205ed8b38146a85e4bf6396ac767b1d (diff) | |
download | ffmpeg-e7513e1286ca1b747485f950b0e1c93612b6736c.tar.gz |
avformat: Read errno before av_log() as the callback from av_log() might affect errno
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/libsmbclient.c')
-rw-r--r-- | libavformat/libsmbclient.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/libsmbclient.c b/libavformat/libsmbclient.c index 892d2db8a4..8290d75927 100644 --- a/libavformat/libsmbclient.c +++ b/libavformat/libsmbclient.c @@ -50,12 +50,14 @@ static av_cold int libsmbc_connect(URLContext *h) libsmbc->ctx = smbc_new_context(); if (!libsmbc->ctx) { + int ret = AVERROR(errno); av_log(h, AV_LOG_ERROR, "Cannot create context: %s.\n", strerror(errno)); - return AVERROR(errno); + return ret; } if (!smbc_init_context(libsmbc->ctx)) { + int ret = AVERROR(errno); av_log(h, AV_LOG_ERROR, "Cannot initialize context: %s.\n", strerror(errno)); - return AVERROR(errno); + return ret; } smbc_set_context(libsmbc->ctx); @@ -68,8 +70,9 @@ static av_cold int libsmbc_connect(URLContext *h) smbc_setWorkgroup(libsmbc->ctx, libsmbc->workgroup); if (smbc_init(NULL, 0) < 0) { + int ret = AVERROR(errno); av_log(h, AV_LOG_ERROR, "Initialization failed: %s\n", strerror(errno)); - return AVERROR(errno); + return ret; } return 0; } @@ -157,8 +160,9 @@ static int libsmbc_read(URLContext *h, unsigned char *buf, int size) int bytes_read; if ((bytes_read = smbc_read(libsmbc->fd, buf, size)) < 0) { + int ret = AVERROR(errno); av_log(h, AV_LOG_ERROR, "Read error: %s\n", strerror(errno)); - return AVERROR(errno); + return ret; } return bytes_read; @@ -170,8 +174,9 @@ static int libsmbc_write(URLContext *h, const unsigned char *buf, int size) int bytes_written; if ((bytes_written = smbc_write(libsmbc->fd, buf, size)) < 0) { + int ret = AVERROR(errno); av_log(h, AV_LOG_ERROR, "Write error: %s\n", strerror(errno)); - return AVERROR(errno); + return ret; } return bytes_written; |