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

Submitted by Andreas Rheinhardt on Sept. 29, 2019, 2:50 a.m.

Details

Message ID 20190929025047.51690-1-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Sept. 29, 2019, 2:50 a.m.
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@gmail.com>
---
 libavformat/utils.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

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 */