summaryrefslogtreecommitdiff
path: root/libavformat/id3v2enc.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/id3v2enc.c
parentcb88cdf7730e309df22ddbbc1ae4ebcd9ebc529e (diff)
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/id3v2enc.c')
-rw-r--r--libavformat/id3v2enc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 9040501869..ee0c4b28a1 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -65,11 +65,11 @@ static void id3v2_encode_string(AVIOContext *pb, const uint8_t *str,
static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext *avioc, const char *str1, const char *str2,
uint32_t tag, enum ID3v2Encoding enc)
{
- int len;
+ int len, ret;
uint8_t *pb;
AVIOContext *dyn_buf;
- if (avio_open_dyn_buf(&dyn_buf) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
+ return ret;
/* check if the strings are ASCII-only and use UTF16 only if
* they're not */
@@ -103,7 +103,7 @@ static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext *avioc, const char *
*/
static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char *key, const char *data)
{
- int len;
+ int len, ret;
uint8_t *pb;
AVIOContext *dyn_buf;
@@ -111,8 +111,8 @@ static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char *
return 0;
}
- if (avio_open_dyn_buf(&dyn_buf) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
+ return ret;
// owner + null byte.
avio_write(dyn_buf, key, strlen(key) + 1);
@@ -359,7 +359,7 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
const char *mimetype = NULL, *desc = "";
int enc = id3->version == 3 ? ID3v2_ENCODING_UTF16BOM :
ID3v2_ENCODING_UTF8;
- int i, len, type = 0;
+ int i, len, type = 0, ret;
/* get the mimetype*/
while (mime->id != AV_CODEC_ID_NONE) {
@@ -393,8 +393,8 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
enc = ID3v2_ENCODING_ISO8859;
/* start writing */
- if (avio_open_dyn_buf(&dyn_buf) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = avio_open_dyn_buf(&dyn_buf)) < 0)
+ return ret;
avio_w8(dyn_buf, enc);
avio_put_str(dyn_buf, mimetype);