diff mbox series

[FFmpeg-devel,1/2] avformat/mux: Remove redundant checks for write errors

Message ID 20200312175408.31391-1-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/mux: Remove redundant checks for write errors
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

Andreas Rheinhardt March 12, 2020, 5:54 p.m. UTC
If writing a packet didn't directly return an error, the AVIOContext's
error flag is checked for errors (if existing) by write_packet(). And if
write_packet() didn't indicate an error, its callers checked the error
flag of the AVIOContext (if existing). The latter check is redundant.

The reason for checking twice lies in the FFmpeg-Libav split: The check
in write_packet() has been added in 9ad1e0c1 in Libav. FFmpeg already
had the other checks (since aec9390a), but when 9ad1e0c1 was merged
(in 1f1c1008), no one noticed the redundant checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/mux.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Michael Niedermayer March 14, 2020, 5:22 p.m. UTC | #1
On Thu, Mar 12, 2020 at 06:54:07PM +0100, Andreas Rheinhardt wrote:
> If writing a packet didn't directly return an error, the AVIOContext's
> error flag is checked for errors (if existing) by write_packet(). And if
> write_packet() didn't indicate an error, its callers checked the error
> flag of the AVIOContext (if existing). The latter check is redundant.
> 
> The reason for checking twice lies in the FFmpeg-Libav split: The check
> in write_packet() has been added in 9ad1e0c1 in Libav. FFmpeg already
> had the other checks (since aec9390a), but when 9ad1e0c1 was merged
> (in 1f1c1008), no one noticed the redundant checks.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/mux.c | 6 ------
>  1 file changed, 6 deletions(-)

will apply the 2 patches of the set

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mux.c b/libavformat/mux.c
index d88746e8c5..bc2eab0c96 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -913,8 +913,6 @@  int av_write_frame(AVFormatContext *s, AVPacket *pkt)
 #endif
 
     ret = write_packet(s, pkt);
-    if (ret >= 0 && s->pb && s->pb->error < 0)
-        ret = s->pb->error;
 
     if (ret >= 0)
         s->streams[pkt->stream_index]->nb_frames++;
@@ -1246,8 +1244,6 @@  int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
 
         if (ret < 0)
             return ret;
-        if(s->pb && s->pb->error)
-            return s->pb->error;
     }
 fail:
     av_packet_unref(pkt);
@@ -1274,8 +1270,6 @@  int av_write_trailer(AVFormatContext *s)
 
         if (ret < 0)
             goto fail;
-        if(s->pb && s->pb->error)
-            goto fail;
     }
 
 fail: