From patchwork Fri Jul 31 11:22:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21408 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1317644998B for ; Fri, 31 Jul 2020 14:23:42 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F127368B8AC; Fri, 31 Jul 2020 14:23:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ADAF968B868 for ; Fri, 31 Jul 2020 14:23:32 +0300 (EEST) Received: by mail-ej1-f65.google.com with SMTP id a21so31052083ejj.10 for ; Fri, 31 Jul 2020 04:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xmggQywGfX3hSZ3hIlVVsBjLbDyZNCzu/QTzfgaylss=; b=HgxDNU8yKf8CKXxn3QOb9x3N0x2Py7CSTx9yCYshDJasOfodk3yYSGHyrLTk325Rli orOGdZwF8chcl68MZY+uGThlbAWrPTjXzvqF4b401iG6U9kEOm3e4cpNOwWy2Zw17Sww fthsh3ZjgxhzEURaaeY/ZwF3G80jvYwRDNhYztj9H0QNzSgpCejws8dYeaeZgxsv/07L 6SxATZUeSmkIHnFj6x6BR8qxP6LYeneI3dj5qjpeE/OsD4PE2bNFubqxEJ7CfaTfA66i NHjetjp9Bx1O36vxqS6eAIa/aXHNPG+heX4KDgLBKYn1FTFBuSD1fEvnYZ3bO5MMwfnA bE5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xmggQywGfX3hSZ3hIlVVsBjLbDyZNCzu/QTzfgaylss=; b=GdJxR1ZkGhoxr3E54k7MYuV5V59J2xIgPlPipFu1zdb+Oev4lNeNq4SNPPTQ8Ufw4k atQk27p0h0WlPHkggbhVrTY67MdqwCliAVoUgc+BaGkXR8m/9ZmOWKqYGVPnxsvDFopB VHY9f3COz85ZnkwellWtwIHKIZXAp7qOEBtXTXrqkgKCIAGsWvo+YN9KvtqnWGC+zAU4 uA4JHq5oiMBBF6xWOrhD8QAh4DP155KXz0+H662XyBwHqPaPhSAmx+3r6fY6TVC09kzc N6pKE62DyGDyRYbEE+yDbEyuFc7XoW/DG9a+5/08+FZ7tMBg/P27tx29kXTAgHqO//Yk Biig== X-Gm-Message-State: AOAM532OoSgIgJgpy+zgwd5EgGWjegWqoUivBo81xirqPx9+kgQ6pVYS 8OaokXP3s0sfAVVtkUlpgQc9zTF4 X-Google-Smtp-Source: ABdhPJwehbGNTlLRLFjcL0IhORvGyCHxtb6fjpYPbtJb7HoFWfm67edzO5b3G9O+l2kQvfnw1MvuZQ== X-Received: by 2002:a17:906:3cc:: with SMTP id c12mr3411180eja.222.1596194611826; Fri, 31 Jul 2020 04:23:31 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id v22sm9284279edq.35.2020.07.31.04.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 04:23:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Jul 2020 13:22:40 +0200 Message-Id: <20200731112241.8948-7-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731112241.8948-1-andreas.rheinhardt@gmail.com> References: <20200731112241.8948-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] avcodec/smacker: Use same variable for return values and errors X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" smacker_decode_header_tree() uses different variables for return values (res) and for errors (err) leading to code like res = foo(bar); if (res < 0) { err = res; goto error; } Given that no positive return value is ever used at all one can simplify the above by removing the intermediate res. Signed-off-by: Andreas Rheinhardt --- libavcodec/smacker.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 4b1f0f1b7c..07fa8887d8 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -182,13 +182,12 @@ static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, */ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size) { - int res; HuffContext huff; HuffContext h[2] = { 0 }; VLC vlc[2] = { { 0 } }; int escapes[3]; DBCtx ctx; - int err = 0; + int err; if(size >= UINT_MAX>>4){ // (((size + 3) >> 2) + 3) << 2 must not overflow av_log(smk->avctx, AV_LOG_ERROR, "size too large\n"); @@ -210,20 +209,17 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int i ? "high" : "low"); continue; } - res = smacker_decode_tree(gb, &h[i], 0, 0); - if (res < 0) { - err = res; + err = smacker_decode_tree(gb, &h[i], 0, 0); + if (err < 0) goto error; - } skip_bits1(gb); if (h[i].current > 1) { - res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length, + err = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length, INIT_VLC_DEFAULT_SIZES(h[i].lengths), INIT_VLC_DEFAULT_SIZES(h[i].bits), INIT_VLC_LE); - if(res < 0) { + if (err < 0) { av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); - err = res; goto error; } } @@ -253,16 +249,15 @@ static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int } *recodes = huff.values; - res = smacker_decode_bigtree(gb, &huff, &ctx, 0); - if (res < 0) { - err = res; + err = smacker_decode_bigtree(gb, &huff, &ctx, 0); + if (err < 0) goto error; - } skip_bits1(gb); if(ctx.last[0] == -1) ctx.last[0] = huff.current++; if(ctx.last[1] == -1) ctx.last[1] = huff.current++; if(ctx.last[2] == -1) ctx.last[2] = huff.current++; + err = 0; error: for (int i = 0; i < 2; i++) { if (vlc[i].table)