Patch Detail
Show a patch.
GET /api/1.1/patches/24030/?format=api
{ "id": 24030, "url": "https://patchwork.libcamera.org/api/1.1/patches/24030/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24030/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250729162101.13836-3-laurent.pinchart@ideasonboard.com>", "date": "2025-07-29T16:21:01", "name": "[v2,2/2] libcamera: v4l2_videodevice: Use scope_exit", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "96ae4484f0dfd04dbb945879a76057bb20e04808", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24030/mbox/", "series": [ { "id": 5348, "url": "https://patchwork.libcamera.org/api/1.1/series/5348/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5348", "date": "2025-07-29T16:20:59", "name": "libcamera: Introduce and use scope_exit", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5348/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24030/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24030/checks/", "tags": {}, "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 BC024C32B5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Jul 2025 16:21:18 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 81E7F691F0;\n\tTue, 29 Jul 2025 18:21:17 +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 85309691F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Jul 2025 18:21:13 +0200 (CEST)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 71EF96DC;\n\tTue, 29 Jul 2025 18:20:30 +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=\"umb0M/76\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753806030;\n\tbh=HQQpoa160C8j3jA6/OnpsPJXD9zOnZ0N0TshqI/S0o4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=umb0M/76YXkIK9VQ21HGtwIbFFsLBz+tx8Lb6ltro3wu4HdHKjibiii+tOmpRuy0K\n\tRyXMul33JwSXxTI1SJl12vpytSJaL3O1dutySEOBqhfyVupAqZd12Pv1ZGqFV7L/TG\n\tRyd6YSoTIiW/Ht9LjbJhj0Jo7yEfwveRERiaoi0s=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Han-Lin Chen <hanlinchen@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>", "Subject": "[PATCH v2 2/2] libcamera: v4l2_videodevice: Use scope_exit", "Date": "Tue, 29 Jul 2025 19:21:01 +0300", "Message-ID": "<20250729162101.13836-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.49.1", "In-Reply-To": "<20250729162101.13836-1-laurent.pinchart@ideasonboard.com>", "References": "<20250729162101.13836-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "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>" }, "content": "The V4L2VideoDevice::queueBuffer() function performs the same cleanup\naction in many error paths. Use scope_exit to simplify it.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/v4l2_videodevice.cpp | 11 +++--------\n 1 file changed, 3 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 71cc7e895d8c..d206244fa9a6 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1668,6 +1668,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n \tif (ret < 0)\n \t\treturn ret;\n \n+\tauto guard = utils::scope_exit{ [&]() { cache_->put(buf.index); } };\n+\n \tbuf.index = ret;\n \tbuf.type = bufferType_;\n \tbuf.memory = memoryType_;\n@@ -1683,15 +1685,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n \t */\n \tif (planes.size() < numV4l2Planes) {\n \t\tLOG(V4L2, Error) << \"Frame buffer has too few planes\";\n-\t\tcache_->put(buf.index);\n-\n \t\treturn -EINVAL;\n \t}\n \n \tif (planes.size() != numV4l2Planes && !buffer->_d()->isContiguous()) {\n \t\tLOG(V4L2, Error) << \"Device format requires contiguous buffer\";\n-\t\tcache_->put(buf.index);\n-\n \t\treturn -EINVAL;\n \t}\n \n@@ -1734,8 +1732,6 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n \t\t\t\tif (i != planes.size() - 1 && bytesused != length) {\n \t\t\t\t\tLOG(V4L2, Error)\n \t\t\t\t\t\t<< \"Holes in multi-planar buffer not supported\";\n-\t\t\t\t\tcache_->put(buf.index);\n-\n \t\t\t\t\treturn -EINVAL;\n \t\t\t\t}\n \t\t\t}\n@@ -1785,8 +1781,6 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Failed to queue buffer \" << buf.index << \": \"\n \t\t\t<< strerror(-ret);\n-\t\tcache_->put(buf.index);\n-\n \t\treturn ret;\n \t}\n \n@@ -1798,6 +1792,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n \n \tqueuedBuffers_[buf.index] = buffer;\n \n+\tguard.release();\n \treturn 0;\n }\n \n", "prefixes": [ "v2", "2/2" ] }