[FFmpeg-cvslog] flvdec: Eliminate completely silly goto
Alexander Strasser
eclipse7 at gmx.net
Sun Aug 11 02:02:18 CEST 2013
On 2013-08-02 12:23 +0200, Diego Biurrun wrote:
> ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Wed Jul 31 23:56:26 2013 +0200| [f900f35ac8db4ac30df6fda1c27502c2ef9e6ba5] | committer: Diego Biurrun
>
> flvdec: Eliminate completely silly goto
Right away, I am a big fan of Dijkstra. Really!
But this change is "completely silly". It has the chance to create a
regression, it produces unneeded noise in the version history, and in
the worst case the error path will have to be brought back at some point
in the future...
Alexander
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f900f35ac8db4ac30df6fda1c27502c2ef9e6ba5
> ---
>
> libavformat/flvdec.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index c5e44ce..11e7be1 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -636,35 +636,32 @@ static void clear_index_entries(AVFormatContext *s, int64_t pos)
> static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
> int64_t dts, int64_t next)
> {
> - int ret = AVERROR_INVALIDDATA, i;
> AVIOContext *pb = s->pb;
> AVStream *st = NULL;
> AMFDataType type;
> char buf[20];
> - int length;
> + int ret, i, length;
>
> type = avio_r8(pb);
> if (type == AMF_DATA_TYPE_MIXEDARRAY)
> avio_seek(pb, 4, SEEK_CUR);
> else if (type != AMF_DATA_TYPE_OBJECT)
> - goto out;
> + return AVERROR_INVALIDDATA;
>
> amf_get_string(pb, buf, sizeof(buf));
> if (strcmp(buf, "type") || avio_r8(pb) != AMF_DATA_TYPE_STRING)
> - goto out;
> + return AVERROR_INVALIDDATA;
>
> amf_get_string(pb, buf, sizeof(buf));
> // FIXME parse it as codec_id
> amf_get_string(pb, buf, sizeof(buf));
> if (strcmp(buf, "text") || avio_r8(pb) != AMF_DATA_TYPE_STRING)
> - goto out;
> + return AVERROR_INVALIDDATA;
>
> length = avio_rb16(pb);
> ret = av_get_packet(s->pb, pkt, length);
> - if (ret < 0) {
> - ret = AVERROR(EIO);
> - goto out;
> - }
> + if (ret < 0)
> + return AVERROR(EIO);
>
> for (i = 0; i < s->nb_streams; i++) {
> st = s->streams[i];
> @@ -675,7 +672,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
> if (i == s->nb_streams) {
> st = create_stream(s, AVMEDIA_TYPE_DATA);
> if (!st)
> - goto out;
> + return AVERROR_INVALIDDATA;
> st->codec->codec_id = AV_CODEC_ID_TEXT;
> }
>
> @@ -688,7 +685,6 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
>
> avio_seek(s->pb, next + 4, SEEK_SET);
>
> -out:
> return ret;
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20130811/20913e1f/attachment.asc>
More information about the ffmpeg-cvslog
mailing list