[{"id":35446,"web_url":"https://patchwork.libcamera.org/comment/35446/","msgid":"<68c0cbf7-0232-4bc1-bf0c-008458efeb76@ideasonboard.com>","date":"2025-08-15T12:15:15","subject":"Re: [PATCH v2 3/8] pipeline: rkisp1: Replace error handling gotos\n\twith utils::exit_scope","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 08. 15. 13:33 keltezéssel, Laurent Pinchart írta:\n> Use utils::exit_scope in PipelineHandlerRkISP1::allocateBuffers() to\n> avoid gotos for error handling.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++++++++----------\n>   1 file changed, 10 insertions(+), 10 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 81370f4cdcba..55d7d4442caf 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -1002,21 +1002,27 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n>   \tunsigned int ipaBufferId = 1;\n>   \tint ret;\n>   \n> +\tauto errorCleanup = utils::scope_exit{ [&]() {\n> +\t\tparamBuffers_.clear();\n> +\t\tstatBuffers_.clear();\n> +\t\tmainPathBuffers_.clear();\n> +\t} };\n> +\n>   \tif (!isRaw_) {\n>   \t\tret = param_->allocateBuffers(kRkISP1MinBufferCount, &paramBuffers_);\n>   \t\tif (ret < 0)\n> -\t\t\tgoto error;\n> +\t\t\treturn ret;\n>   \n>   \t\tret = stat_->allocateBuffers(kRkISP1MinBufferCount, &statBuffers_);\n>   \t\tif (ret < 0)\n> -\t\t\tgoto error;\n> +\t\t\treturn ret;\n>   \t}\n>   \n>   \t/* If the dewarper is being used, allocate internal buffers for ISP. */\n>   \tif (useDewarper_) {\n>   \t\tret = mainPath_.exportBuffers(kRkISP1MinBufferCount, &mainPathBuffers_);\n>   \t\tif (ret < 0)\n> -\t\t\tgoto error;\n> +\t\t\treturn ret;\n>   \n>   \t\tfor (std::unique_ptr<FrameBuffer> &buffer : mainPathBuffers_)\n>   \t\t\tavailableMainPathBuffers_.push(buffer.get());\n> @@ -1038,14 +1044,8 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n>   \n>   \tdata->ipa_->mapBuffers(data->ipaBuffers_);\n>   \n> +\terrorCleanup.release();\n>   \treturn 0;\n> -\n> -error:\n> -\tparamBuffers_.clear();\n> -\tstatBuffers_.clear();\n> -\tmainPathBuffers_.clear();\n> -\n> -\treturn ret;\n>   }\n>   \n>   int PipelineHandlerRkISP1::freeBuffers(Camera *camera)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AD94BBDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Aug 2025 12:15:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E79669257;\n\tFri, 15 Aug 2025 14:15:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE30861443\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Aug 2025 14:15:19 +0200 (CEST)","from [192.168.33.21] (185.221.141.188.nat.pool.zt.hu\n\t[185.221.141.188])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B12EB56D;\n\tFri, 15 Aug 2025 14:14:24 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ET4YjhbE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755260064;\n\tbh=Dtisiqkm71i0OP3zNoGxor03CZkVHxKQExDtdPMRgiU=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=ET4YjhbERD4sNDjn2Ef2BRc3hCsuTMXnifJUNsHQrY9osGOUGcdKW8R6d86JKZRdp\n\t+nRQ9/R0qB+lPzk4Shtnh+XqoMptH+UYUTD6hCWPEwnH45Bdlb+/KllMTJ2gseDkS9\n\trVDICkhcCTCt6r+sjE13OHs+qN6VxsOQUCrGYzbc=","Message-ID":"<68c0cbf7-0232-4bc1-bf0c-008458efeb76@ideasonboard.com>","Date":"Fri, 15 Aug 2025 14:15:15 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 3/8] pipeline: rkisp1: Replace error handling gotos\n\twith utils::exit_scope","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"=?utf-8?q?Daniel_R=C3=A1kos?= <daniel.rakos@rastergrid.com>","References":"<20250815113400.20623-1-laurent.pinchart@ideasonboard.com>\n\t<20250815113400.20623-4-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250815113400.20623-4-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35518,"web_url":"https://patchwork.libcamera.org/comment/35518/","msgid":"<47r2fjvlkt4552y3amzg2bf63iifgdvsuwh7i7pmdkj3uxlfga@pjjulenxm3sl>","date":"2025-08-19T15:23:01","subject":"Re: [PATCH v2 3/8] pipeline: rkisp1: Replace error handling gotos\n\twith utils::exit_scope","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Laurent\n\nOn Fri, Aug 15, 2025 at 02:33:55PM +0300, Laurent Pinchart wrote:\n> Use utils::exit_scope in PipelineHandlerRkISP1::allocateBuffers() to\n> avoid gotos for error handling.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++++++++----------\n>  1 file changed, 10 insertions(+), 10 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 81370f4cdcba..55d7d4442caf 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -1002,21 +1002,27 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n>  \tunsigned int ipaBufferId = 1;\n>  \tint ret;\n>\n> +\tauto errorCleanup = utils::scope_exit{ [&]() {\n> +\t\tparamBuffers_.clear();\n> +\t\tstatBuffers_.clear();\n> +\t\tmainPathBuffers_.clear();\n> +\t} };\n> +\n>  \tif (!isRaw_) {\n>  \t\tret = param_->allocateBuffers(kRkISP1MinBufferCount, &paramBuffers_);\n>  \t\tif (ret < 0)\n> -\t\t\tgoto error;\n> +\t\t\treturn ret;\n>\n>  \t\tret = stat_->allocateBuffers(kRkISP1MinBufferCount, &statBuffers_);\n>  \t\tif (ret < 0)\n> -\t\t\tgoto error;\n> +\t\t\treturn ret;\n>  \t}\n>\n>  \t/* If the dewarper is being used, allocate internal buffers for ISP. */\n>  \tif (useDewarper_) {\n>  \t\tret = mainPath_.exportBuffers(kRkISP1MinBufferCount, &mainPathBuffers_);\n>  \t\tif (ret < 0)\n> -\t\t\tgoto error;\n> +\t\t\treturn ret;\n>\n>  \t\tfor (std::unique_ptr<FrameBuffer> &buffer : mainPathBuffers_)\n>  \t\t\tavailableMainPathBuffers_.push(buffer.get());\n> @@ -1038,14 +1044,8 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n>\n>  \tdata->ipa_->mapBuffers(data->ipaBuffers_);\n>\n> +\terrorCleanup.release();\n>  \treturn 0;\n> -\n> -error:\n> -\tparamBuffers_.clear();\n> -\tstatBuffers_.clear();\n> -\tmainPathBuffers_.clear();\n> -\n> -\treturn ret;\n>  }\n>\n>  int PipelineHandlerRkISP1::freeBuffers(Camera *camera)\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DAA01BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Aug 2025 15:23:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EFBDB692DF;\n\tTue, 19 Aug 2025 17:23:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42A7E692D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Aug 2025 17:23:05 +0200 (CEST)","from ideasonboard.com (mob-5-90-52-92.net.vodafone.it [5.90.52.92])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F2A2B1F0E;\n\tTue, 19 Aug 2025 17:22:06 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aa3WyPzk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755616927;\n\tbh=ptbFicf074ivq08/KOFpAkIgJqmHuke4ZL7yZ806+6Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=aa3WyPzkk11vVKHohdelpYsclAmmZOk2UmQoVggriUpPuFBr0+tr3N1nIPuC27FSI\n\tb4qD/nt4KKnA4Qe7rdCtJG7jnAFx4qj6I+81bHEm4RnSlIUjlFQM1AwRLEcqrKITtv\n\tMTpRJI+ArkcQbQckA/59I6f3j6jyYA6JYxcnoKwU=","Date":"Tue, 19 Aug 2025 17:23:01 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  Daniel =?utf-8?b?UsOha29z?=\n\t<daniel.rakos@rastergrid.com>","Subject":"Re: [PATCH v2 3/8] pipeline: rkisp1: Replace error handling gotos\n\twith utils::exit_scope","Message-ID":"<47r2fjvlkt4552y3amzg2bf63iifgdvsuwh7i7pmdkj3uxlfga@pjjulenxm3sl>","References":"<20250815113400.20623-1-laurent.pinchart@ideasonboard.com>\n\t<20250815113400.20623-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250815113400.20623-4-laurent.pinchart@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]