diff mbox series

[FFmpeg-devel,2/4] avformat/udp: properly use return value of pthread_cond_timedwait

Message ID 20200116002016.4528-2-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avformat/udp: add newline after warning
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Marton Balint Jan. 16, 2020, 12:20 a.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/udp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/udp.c b/libavformat/udp.c
index e42a069b24..c92fcc49a1 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -978,9 +978,10 @@  static int udp_read(URLContext *h, uint8_t *buf, int size)
                 int64_t t = av_gettime() + 100000;
                 struct timespec tv = { .tv_sec  =  t / 1000000,
                                        .tv_nsec = (t % 1000000) * 1000 };
-                if (pthread_cond_timedwait(&s->cond, &s->mutex, &tv) < 0) {
+                int err = pthread_cond_timedwait(&s->cond, &s->mutex, &tv);
+                if (err) {
                     pthread_mutex_unlock(&s->mutex);
-                    return AVERROR(errno == ETIMEDOUT ? EAGAIN : errno);
+                    return AVERROR(err == ETIMEDOUT ? EAGAIN : err);
                 }
                 nonblock = 1;
             }