Patch Detail
Show a patch.
GET /api/1.1/patches/24059/?format=api
{ "id": 24059, "url": "https://patchwork.libcamera.org/api/1.1/patches/24059/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24059/", "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": "<20250804233152.11538-3-laurent.pinchart@ideasonboard.com>", "date": "2025-08-04T23:31:51", "name": "[v4,2/2] libcamera: v4l2_videodevice: Use scope_exit", "commit_ref": "4e567d1981aa177f2db9f442c573b881c25eb963", "pull_url": null, "state": "accepted", "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/24059/mbox/", "series": [ { "id": 5357, "url": "https://patchwork.libcamera.org/api/1.1/series/5357/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5357", "date": "2025-08-04T23:31:49", "name": "libcamera: Introduce and use scope_exit", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5357/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24059/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24059/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 3C440BE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 4 Aug 2025 23:32:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 973CA69225;\n\tTue, 5 Aug 2025 01:32:10 +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 CC9AA69222\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 5 Aug 2025 01:32:08 +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 5101832FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 5 Aug 2025 01:31:21 +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=\"a27jDZL5\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754350281;\n\tbh=HQQpoa160C8j3jA6/OnpsPJXD9zOnZ0N0TshqI/S0o4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=a27jDZL5Shtwr8s5e7KQUd1C85/WdM++IGv+n5Po7//8pM/BzIK3Y1ntcECeTB55Z\n\tRI3PeK+rywa44myN26NEnYV7h9wlfGrA3udk9CUkp5mM6C6THmg9BqrvM2coBgOWFP\n\tBAeTPQan14QQtPxZbFmKTfqlJHU7G81FUbPKKYuU=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v4 2/2] libcamera: v4l2_videodevice: Use scope_exit", "Date": "Tue, 5 Aug 2025 02:31:51 +0300", "Message-ID": "<20250804233152.11538-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.49.1", "In-Reply-To": "<20250804233152.11538-1-laurent.pinchart@ideasonboard.com>", "References": "<20250804233152.11538-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": [ "v4", "2/2" ] }