From patchwork Fri Aug 15 11:33:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24133 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A431EBEFBE for ; Fri, 15 Aug 2025 11:34:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0FDE869263; Fri, 15 Aug 2025 13:34:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jeZgBCYk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 01EFA61443 for ; Fri, 15 Aug 2025 13:34:25 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 02AC2605; Fri, 15 Aug 2025 13:33:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257610; bh=nsbVr4+Y4gYjD5ICyepngMpK8g6aNzDw3bHDF/himBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jeZgBCYkCKUM/gl1kbjFpqo+6cvZhTadxbC3QbKlDkQUaOcb6tj/oY+hEUKAJyc3d 6snGoZQ/7EXwBsOAdL8U0d8dS/dn7QKa9dRTzdio7gmV9lKxpreSR1hGadJu+HUE8s +tpHshIXByeGZSlCl2n8mF5v44WUtDFq18aG7uhg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 3/8] pipeline: rkisp1: Replace error handling gotos with utils::exit_scope Date: Fri, 15 Aug 2025 14:33:55 +0300 Message-ID: <20250815113400.20623-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use utils::exit_scope in PipelineHandlerRkISP1::allocateBuffers() to avoid gotos for error handling. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 81370f4cdcba..55d7d4442caf 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1002,21 +1002,27 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) unsigned int ipaBufferId = 1; int ret; + auto errorCleanup = utils::scope_exit{ [&]() { + paramBuffers_.clear(); + statBuffers_.clear(); + mainPathBuffers_.clear(); + } }; + if (!isRaw_) { ret = param_->allocateBuffers(kRkISP1MinBufferCount, ¶mBuffers_); if (ret < 0) - goto error; + return ret; ret = stat_->allocateBuffers(kRkISP1MinBufferCount, &statBuffers_); if (ret < 0) - goto error; + return ret; } /* If the dewarper is being used, allocate internal buffers for ISP. */ if (useDewarper_) { ret = mainPath_.exportBuffers(kRkISP1MinBufferCount, &mainPathBuffers_); if (ret < 0) - goto error; + return ret; for (std::unique_ptr &buffer : mainPathBuffers_) availableMainPathBuffers_.push(buffer.get()); @@ -1038,14 +1044,8 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) data->ipa_->mapBuffers(data->ipaBuffers_); + errorCleanup.release(); return 0; - -error: - paramBuffers_.clear(); - statBuffers_.clear(); - mainPathBuffers_.clear(); - - return ret; } int PipelineHandlerRkISP1::freeBuffers(Camera *camera)