From c1e439d7e9abab3cebdc937636393b1656e095d9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 10 Dec 2019 22:59:53 +0100 Subject: avformat: Forward errors where possible It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt Signed-off-by: Michael Niedermayer --- libavformat/avisynth.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libavformat/avisynth.c') diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 5dfe94ae0c..55a2efd884 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -640,7 +640,7 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, AVS_VideoFrame *frame; unsigned char *dst_p; const unsigned char *src_p; - int n, i, plane, rowsize, planeheight, pitch, bits; + int n, i, plane, rowsize, planeheight, pitch, bits, ret; const char *error; int avsplus av_unused; @@ -676,8 +676,8 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, if (!pkt->size) return AVERROR_UNKNOWN; - if (av_new_packet(pkt, pkt->size) < 0) - return AVERROR(ENOMEM); + if ((ret = av_new_packet(pkt, pkt->size)) < 0) + return ret; pkt->pts = n; pkt->dts = n; @@ -739,7 +739,7 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, { AviSynthContext *avs = s->priv_data; AVRational fps, samplerate; - int samples; + int samples, ret; int64_t n; const char *error; @@ -782,8 +782,8 @@ static int avisynth_read_packet_audio(AVFormatContext *s, AVPacket *pkt, if (!pkt->size) return AVERROR_UNKNOWN; - if (av_new_packet(pkt, pkt->size) < 0) - return AVERROR(ENOMEM); + if ((ret = av_new_packet(pkt, pkt->size)) < 0) + return ret; pkt->pts = n; pkt->dts = n; -- cgit v1.2.3