[FFmpeg-devel] [PATCH] avformat/utils: Fix confusing return value

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sun Sep 29 05:50:47 EEST 2019


Replace a return ret with return 0 to more clearly indicate success.
Also don't use separate ret and err variables.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/utils.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7545d75d5b..f5034c684f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -832,7 +832,7 @@ static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
 
 int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    int ret, i, err;
+    int i, err;
     AVStream *st;
 
     pkt->data = NULL;
@@ -856,17 +856,17 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             }
         }
 
-        ret = s->iformat->read_packet(s, pkt);
-        if (ret < 0) {
+        err = s->iformat->read_packet(s, pkt);
+        if (err < 0) {
             av_packet_unref(pkt);
 
             /* Some demuxers return FFERROR_REDO when they consume
                data and discard it (ignored streams, junk, extradata).
                We must re-call the demuxer to get the real packet. */
-            if (ret == FFERROR_REDO)
+            if (err == FFERROR_REDO)
                 continue;
-            if (!pktl || ret == AVERROR(EAGAIN))
-                return ret;
+            if (!pktl || err == AVERROR(EAGAIN))
+                return err;
             for (i = 0; i < s->nb_streams; i++) {
                 st = s->streams[i];
                 if (st->probe_packets || st->request_probe > 0)
@@ -917,7 +917,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base);
 
         if (!pktl && st->request_probe <= 0)
-            return ret;
+            return 0;
 
         err = ff_packet_list_put(&s->internal->raw_packet_buffer,
                                  &s->internal->raw_packet_buffer_end,
@@ -1597,7 +1597,6 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
              * really terminate parsing */
             break;
         }
-        ret = 0;
         st  = s->streams[pkt->stream_index];
 
         /* update context if required */
-- 
2.21.0



More information about the ffmpeg-devel mailing list