summaryrefslogtreecommitdiff
path: root/libavformat/ape.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-10 22:59:53 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-12 19:25:33 +0100
commitc1e439d7e9abab3cebdc937636393b1656e095d9 (patch)
treebe0ae941a23b62c42b152e2b9aa0a22f8c793d4e /libavformat/ape.c
parentcb88cdf7730e309df22ddbbc1ae4ebcd9ebc529e (diff)
downloadffmpeg-c1e439d7e9abab3cebdc937636393b1656e095d9.tar.gz
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 <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/ape.c')
-rw-r--r--libavformat/ape.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/libavformat/ape.c b/libavformat/ape.c
index 977e6f3d18..e31a00dc96 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -163,7 +163,7 @@ static int ape_read_header(AVFormatContext * s)
APEContext *ape = s->priv_data;
AVStream *st;
uint32_t tag;
- int i;
+ int i, ret;
int total_blocks, final_size = 0;
int64_t pts, file_size;
@@ -358,8 +358,8 @@ static int ape_read_header(AVFormatContext * s)
st->duration = total_blocks;
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
- if (ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE))
- return AVERROR(ENOMEM);
+ if ((ret = ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) < 0)
+ return ret;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
@@ -386,14 +386,16 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
int nblocks;
APEContext *ape = s->priv_data;
uint32_t extra_size = 8;
+ int64_t ret64;
if (avio_feof(s->pb))
return AVERROR_EOF;
if (ape->currentframe >= ape->totalframes)
return AVERROR_EOF;
- if (avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET) < 0)
- return AVERROR(EIO);
+ ret64 = avio_seek(s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
+ if (ret64 < 0)
+ return ret64;
/* Calculate how many blocks there are in this frame */
if (ape->currentframe == (ape->totalframes - 1))
@@ -409,8 +411,9 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
return AVERROR(EIO);
}
- if (av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size) < 0)
- return AVERROR(ENOMEM);
+ ret = av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size);
+ if (ret < 0)
+ return ret;
AV_WL32(pkt->data , nblocks);
AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
@@ -447,12 +450,13 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
AVStream *st = s->streams[stream_index];
APEContext *ape = s->priv_data;
int index = av_index_search_timestamp(st, timestamp, flags);
+ int64_t ret;
if (index < 0)
return -1;
- if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
- return -1;
+ if ((ret = avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET)) < 0)
+ return ret;
ape->currentframe = index;
return 0;
}