From patchwork Sun Sep 13 02:57:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22314 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 59B20449E91 for ; Sun, 13 Sep 2020 05:58:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3610C68BBC0; Sun, 13 Sep 2020 05:58:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D6B168BBAC for ; Sun, 13 Sep 2020 05:58:27 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id j2so15063390wrx.7 for ; Sat, 12 Sep 2020 19:58:27 -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=9T0xCG93nG+QLN73d0RNn38tWm9eRPrdUkWqMwpV9qw=; b=ZqDWMVdu9+crq61Coe+hJfl4mwt4mInGdQj6LJuI7FYKkVJTHOCXkCHAolXbndflRQ P/V2LsuwErbeQrCbbWrTIWHx8dVO0jcygF0VlIDnRoRF7sK70COaZ8RCgVAACpvDsVON J2eVsfOYzW70EpRQpT3I3DS+uyHl41J67Diw65ZHd83g4Uykcl98d5A249H8XQXUoDZN 2fo+RcxV6vXPAO7T+12k0DDzGISqvo+r/4wLhzqhilzWPI7o7L2X0vOK4VdQOb+QvsB4 g1STZh8CWTzxIo/RMQEX6HlfsS16a66F2qZoOsSBy6B0FW4HQw7vfwAlGHMAtcjkJRo6 QN5w== 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=9T0xCG93nG+QLN73d0RNn38tWm9eRPrdUkWqMwpV9qw=; b=EKHZrakk9AmNrz+9dl4uz1IdZWt5/fISAHf0kiBsdAgT7VgmGjNcwsLyf6Q/A2uJ3c 0RHjgwWu5B339EQDOLG4A8E1YIJLGPZtl6QlerrGSCi58qgR73WRUuJDEFLYi8J25plz tDRXGRCD54Ud+YAwp2dnzoJzCZofwiS0rel2vDRvk4wpNwoWuRQt6rLdddyIS5X+7ChR 51qiIdNQMCd/+NdwBwEDGc7n1hA39iZO1bj5DI66iBCBbEpTVObissgHQNhSINKxy+Hl Qud3xTz0/Fk+S1eoXxT/Sls0UobpIy+KQofFZAg8Aves9lhJrHhlW58Ib12sApDa4uM5 vmig== X-Gm-Message-State: AOAM533nqy3f9TZBx06qz12DHH4DPaAvGfpMuuMMz0fFWqgelxrp6OFu YZb0VMy1ZF0m4utkRh20aKW12bTOqBE= X-Google-Smtp-Source: ABdhPJwDduIedNjG6jmUHtOz2Uiz5nF9o2AV49TzDFLsYdJexCiC+5s5tWaE+bxV48le+AZdnEXWiw== X-Received: by 2002:adf:ec87:: with SMTP id z7mr9814444wrn.57.1599965906603; Sat, 12 Sep 2020 19:58:26 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:26 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:45 +0200 Message-Id: <20200913025753.274772-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/16] avcodec/roqaudioenc: Avoid redundant free of unallocated buffer 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" If allocating a buffer in RoQ DPCM encoder's init function failed, the close function would be called manually; all this function does is freeing said buffer, but given that it has not been allocated at all, this is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/roqaudioenc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 5154604be8..c09212d3d1 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -53,7 +53,6 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx) static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) { ROQDPCMContext *context = avctx->priv_data; - int ret; if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Audio must be mono or stereo\n"); @@ -70,17 +69,12 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * avctx->channels * sizeof(*context->frame_buffer)); - if (!context->frame_buffer) { - ret = AVERROR(ENOMEM); - goto error; - } + if (!context->frame_buffer) + return AVERROR(ENOMEM); context->lastSample[0] = context->lastSample[1] = 0; return 0; -error: - roq_dpcm_encode_close(avctx); - return ret; } static unsigned char dpcm_predict(short *previous, short current)