Message ID | 20200417140555.6181-1-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | 6b0c94780d8087772a718bfa8fdcb46b1770b987 |
Headers | show |
Series | [FFmpeg-devel] libavcodec/avpacket: Don't simply forward return value of av_dict_set() | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
Andreas Rheinhardt: > The documentation of av_dict_set() states that values >= 0 indicate > success, whereas av_packet_unpack_dictionary() implies that return > values > 0 are impossible. So only forward the return value of > av_dict_set() in av_packet_unpack_dictionary() on error. > > (Btw: av_dict_set() does currently not return values > 0.) > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > libavcodec/avpacket.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c > index ad020eef13..360722c365 100644 > --- a/libavcodec/avpacket.c > +++ b/libavcodec/avpacket.c > @@ -525,10 +525,10 @@ fail: > int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) > { > const uint8_t *end; > - int ret = 0; > + int ret; > > if (!dict || !data || !size) > - return ret; > + return 0; > end = data + size; > if (size && end[-1]) > return AVERROR_INVALIDDATA; > @@ -541,11 +541,11 @@ int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di > > ret = av_dict_set(dict, key, val, 0); > if (ret < 0) > - break; > + return ret; > data = val + strlen(val) + 1; > } > > - return ret; > + return 0; > } > > int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, > Will apply tomorrow if there are no objections. - Andreas
Andreas Rheinhardt: > Andreas Rheinhardt: >> The documentation of av_dict_set() states that values >= 0 indicate >> success, whereas av_packet_unpack_dictionary() implies that return >> values > 0 are impossible. So only forward the return value of >> av_dict_set() in av_packet_unpack_dictionary() on error. >> >> (Btw: av_dict_set() does currently not return values > 0.) >> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> >> --- >> libavcodec/avpacket.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c >> index ad020eef13..360722c365 100644 >> --- a/libavcodec/avpacket.c >> +++ b/libavcodec/avpacket.c >> @@ -525,10 +525,10 @@ fail: >> int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) >> { >> const uint8_t *end; >> - int ret = 0; >> + int ret; >> >> if (!dict || !data || !size) >> - return ret; >> + return 0; >> end = data + size; >> if (size && end[-1]) >> return AVERROR_INVALIDDATA; >> @@ -541,11 +541,11 @@ int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di >> >> ret = av_dict_set(dict, key, val, 0); >> if (ret < 0) >> - break; >> + return ret; >> data = val + strlen(val) + 1; >> } >> >> - return ret; >> + return 0; >> } >> >> int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, >> > Will apply tomorrow if there are no objections. > > - Andreas > Applied. - Andreas
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index ad020eef13..360722c365 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -525,10 +525,10 @@ fail: int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) { const uint8_t *end; - int ret = 0; + int ret; if (!dict || !data || !size) - return ret; + return 0; end = data + size; if (size && end[-1]) return AVERROR_INVALIDDATA; @@ -541,11 +541,11 @@ int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di ret = av_dict_set(dict, key, val, 0); if (ret < 0) - break; + return ret; data = val + strlen(val) + 1; } - return ret; + return 0; } int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
The documentation of av_dict_set() states that values >= 0 indicate success, whereas av_packet_unpack_dictionary() implies that return values > 0 are impossible. So only forward the return value of av_dict_set() in av_packet_unpack_dictionary() on error. (Btw: av_dict_set() does currently not return values > 0.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/avpacket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)