diff mbox series

[FFmpeg-devel,v2,7/7] avcodec/adpcmenc: remove gotos and error label

Message ID 1590728554-23471-7-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/7] avcodec/h264dec: cosmetics
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Limin Wang May 29, 2020, 5:02 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/adpcmenc.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Limin Wang May 30, 2020, 12:05 p.m. UTC | #1
On Fri, May 29, 2020 at 01:02:34PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/adpcmenc.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index bcb6783c0c..52f0f67958 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -65,7 +65,6 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>      ADPCMEncodeContext *s = avctx->priv_data;
>      uint8_t *extradata;
>      int i;
> -    int ret = AVERROR(ENOMEM);
>  
>      if (avctx->channels > 2) {
>          av_log(avctx, AV_LOG_ERROR, "only stereo or mono is supported\n");
> @@ -120,7 +119,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>          avctx->bits_per_coded_sample = 4;
>          avctx->block_align    = BLKSIZE;
>          if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE)))
> -            goto error;
> +            return AVERROR(ENOMEM);
>          avctx->extradata_size = 32;
>          extradata = avctx->extradata;
>          bytestream_put_le16(&extradata, avctx->frame_size);
> @@ -140,8 +139,7 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>              avctx->sample_rate != 44100) {
>              av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
>                     "22050 or 44100\n");
> -            ret = AVERROR(EINVAL);
> -            goto error;
> +            return AVERROR(EINVAL);
>          }
>          avctx->frame_size = 512 * (avctx->sample_rate / 11025);
>          break;
> @@ -150,13 +148,10 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>          avctx->block_align = BLKSIZE;
>          break;
>      default:
> -        ret = AVERROR(EINVAL);
> -        goto error;
> +        return AVERROR(EINVAL);
>      }
>  
>      return 0;
> -error:
> -    return ret;
>  }
>  
>  static av_cold int adpcm_encode_close(AVCodecContext *avctx)
> @@ -725,8 +720,6 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
>      avpkt->size = pkt_size;
>      *got_packet_ptr = 1;
>      return 0;
> -error:
> -    return AVERROR(ENOMEM);
>  }
>  

any objection for the remove for the gotos? if no, I'll continue to work on removing more such condition.


>  static const enum AVSampleFormat sample_fmts[] = {
> -- 
> 2.21.0
>
diff mbox series

Patch

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index bcb6783c0c..52f0f67958 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -65,7 +65,6 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
     ADPCMEncodeContext *s = avctx->priv_data;
     uint8_t *extradata;
     int i;
-    int ret = AVERROR(ENOMEM);
 
     if (avctx->channels > 2) {
         av_log(avctx, AV_LOG_ERROR, "only stereo or mono is supported\n");
@@ -120,7 +119,7 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
         avctx->bits_per_coded_sample = 4;
         avctx->block_align    = BLKSIZE;
         if (!(avctx->extradata = av_malloc(32 + AV_INPUT_BUFFER_PADDING_SIZE)))
-            goto error;
+            return AVERROR(ENOMEM);
         avctx->extradata_size = 32;
         extradata = avctx->extradata;
         bytestream_put_le16(&extradata, avctx->frame_size);
@@ -140,8 +139,7 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
             avctx->sample_rate != 44100) {
             av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, "
                    "22050 or 44100\n");
-            ret = AVERROR(EINVAL);
-            goto error;
+            return AVERROR(EINVAL);
         }
         avctx->frame_size = 512 * (avctx->sample_rate / 11025);
         break;
@@ -150,13 +148,10 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
         avctx->block_align = BLKSIZE;
         break;
     default:
-        ret = AVERROR(EINVAL);
-        goto error;
+        return AVERROR(EINVAL);
     }
 
     return 0;
-error:
-    return ret;
 }
 
 static av_cold int adpcm_encode_close(AVCodecContext *avctx)
@@ -725,8 +720,6 @@  static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     avpkt->size = pkt_size;
     *got_packet_ptr = 1;
     return 0;
-error:
-    return AVERROR(ENOMEM);
 }
 
 static const enum AVSampleFormat sample_fmts[] = {