Show a patch.

GET /api/patches/23973/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 23973,
    "url": "https://patchwork.libcamera.org/api/patches/23973/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23973/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20250725235311.7280-1-laurent.pinchart@ideasonboard.com>",
    "date": "2025-07-25T23:53:11",
    "name": "libcamera: v4l2_videodevice: Use ScopeExitActions",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": false,
    "hash": "06c4fe77eca9b63dcc911b821221f14503217a42",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23973/mbox/",
    "series": [
        {
            "id": 5336,
            "url": "https://patchwork.libcamera.org/api/series/5336/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5336",
            "date": "2025-07-25T23:53:11",
            "name": "libcamera: v4l2_videodevice: Use ScopeExitActions",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5336/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23973/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23973/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 CD9D0C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Jul 2025 23:53:35 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CC2756910B;\n\tSat, 26 Jul 2025 01:53:34 +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 F0DFC614C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Jul 2025 01:53:17 +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 8FFDC1387; \n\tSat, 26 Jul 2025 01:52:37 +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=\"UHTNJY1+\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753487557;\n\tbh=5ZTWa97WQ/4ckUp3XRI6PgEK11FuWBe4gAALhFnMWV4=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=UHTNJY1+/yDRemb/E7+sXNmln6hn6l3JdVaEhKjI6KdJzy2T4LNj8ImzY9zv732qx\n\tgJJiRfGxhxePPWBleDO96uYq3mfSksUTFvmgkJagh1NOQxol3iV7CGBNfEcit63fck\n\tHokNUWM+pS9MF2EL2OxJNGwxuKjza4N6QimnJxK8=",
        "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] libcamera: v4l2_videodevice: Use ScopeExitActions",
        "Date": "Sat, 26 Jul 2025 02:53:11 +0300",
        "Message-ID": "<20250725235311.7280-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.49.1",
        "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 ScopeExitActions to simplify it.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/v4l2_videodevice.cpp | 12 ++++--------\n 1 file changed, 4 insertions(+), 8 deletions(-)\n\n\nbase-commit: b65df7e7554b45e2d3d7fdb5b37c2ab7df3db4fe\n--\nRegards,\n\nLaurent Pinchart",
    "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 71cc7e895d8c..5f57e546e80b 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1646,6 +1646,7 @@ int V4L2VideoDevice::releaseBuffers()\n int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n {\n \tstruct v4l2_plane v4l2Planes[VIDEO_MAX_PLANES] = {};\n+\tutils::ScopeExitActions actions;\n \tstruct v4l2_buffer buf = {};\n \tint ret;\n\n@@ -1668,6 +1669,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n \tif (ret < 0)\n \t\treturn ret;\n\n+\tactions += [&]() { cache_->put(buf.index); };\n+\n \tbuf.index = ret;\n \tbuf.type = bufferType_;\n \tbuf.memory = memoryType_;\n@@ -1683,15 +1686,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 +1733,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 +1782,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 +1793,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n\n \tqueuedBuffers_[buf.index] = buffer;\n\n+\tactions.release();\n \treturn 0;\n }\n\n",
    "prefixes": []
}