Patch Detail
Show a patch.
GET /api/patches/12104/?format=api
{ "id": 12104, "url": "https://patchwork.libcamera.org/api/patches/12104/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12104/", "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": "<20210426001220.15599-2-laurent.pinchart@ideasonboard.com>", "date": "2021-04-26T00:12:18", "name": "[libcamera-devel,v6,1/3] libcamera: V4L2Device: Replace VLA with std::vector in getControls()", "commit_ref": "3252631fbdfce8d63353a2f77f1c1b9aa87d9855", "pull_url": null, "state": "accepted", "archived": false, "hash": "48af3786d1acf42e9d4912e56a7d16956e4d5c05", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": { "id": 14, "url": "https://patchwork.libcamera.org/api/users/14/?format=api", "username": "pinchartl", "first_name": "Laurent", "last_name": "Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/12104/mbox/", "series": [ { "id": 1973, "url": "https://patchwork.libcamera.org/api/series/1973/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1973", "date": "2021-04-26T00:12:17", "name": "libcamera: V4L2Device: VLA removal", "version": 6, "mbox": "https://patchwork.libcamera.org/series/1973/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12104/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12104/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 4594ABDC92\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Apr 2021 00:12:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0454D68885;\n\tMon, 26 Apr 2021 02:12:37 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A85FD6887A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Apr 2021 02:12:33 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6E90B4FB;\n\tMon, 26 Apr 2021 02:12:32 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"t93uwmX9\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619395952;\n\tbh=U15f0F5yad+iJnvhaQL5E4C9BeHaDrqdveadDCgJ3qs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=t93uwmX9qN6fK3s4hzPPvvTLOOzBDlz2UGt6UH0M9I2kSkroCXVdFMjFCexaG+myd\n\tFsT4vgoTvysWGtVQ6kPsNJKqfN7GU7/r6Gp7JhOC50tjVWRai5VBfZ9G1mZZdRs4rE\n\tNd1npTd2hDfA5+Wa63Q2vvlu7k3kAG9ftm8T2Qxs=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 26 Apr 2021 03:12:18 +0300", "Message-Id": "<20210426001220.15599-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.28.1", "In-Reply-To": "<20210426001220.15599-1-laurent.pinchart@ideasonboard.com>", "References": "<20210426001220.15599-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v6 1/3] libcamera: V4L2Device: Replace VLA\n\twith std::vector in getControls()", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Hirokazu Honda <hiroh@chromium.org>\n\nThe original code uses Variable-Length-Array, which is not officially\nsupported in C++. This replaces the array with std::vector.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/v4l2_device.cpp | 28 ++++++++++++++--------------\n 1 file changed, 14 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex decd19ef5281..3a4df4f6c098 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -173,8 +173,7 @@ void V4L2Device::close()\n */\n ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n {\n-\tunsigned int count = ids.size();\n-\tif (count == 0)\n+\tif (ids.empty())\n \t\treturn {};\n \n \tControlList ctrls{ controls_ };\n@@ -196,14 +195,17 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n \t\tctrls.set(id, {});\n \t}\n \n-\tstruct v4l2_ext_control v4l2Ctrls[count];\n-\tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n+\tstd::vector<v4l2_ext_control> v4l2Ctrls(ids.size());\n+\tmemset(v4l2Ctrls.data(), 0, sizeof(v4l2_ext_control) * ctrls.size());\n \n \tunsigned int i = 0;\n \tfor (auto &ctrl : ctrls) {\n \t\tunsigned int id = ctrl.first;\n \t\tconst struct v4l2_query_ext_ctrl &info = controlInfo_[id];\n \n+\t\tv4l2_ext_control &v4l2Ctrl = v4l2Ctrls[i++];\n+\t\tv4l2Ctrl.id = id;\n+\n \t\tif (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) {\n \t\t\tControlType type;\n \n@@ -223,25 +225,22 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n \t\t\tvalue.reserve(type, true, info.elems);\n \t\t\tSpan<uint8_t> data = value.data();\n \n-\t\t\tv4l2Ctrls[i].p_u8 = data.data();\n-\t\t\tv4l2Ctrls[i].size = data.size();\n+\t\t\tv4l2Ctrl.p_u8 = data.data();\n+\t\t\tv4l2Ctrl.size = data.size();\n \t\t}\n-\n-\t\tv4l2Ctrls[i].id = id;\n-\t\ti++;\n \t}\n \n \tstruct v4l2_ext_controls v4l2ExtCtrls = {};\n \tv4l2ExtCtrls.which = V4L2_CTRL_WHICH_CUR_VAL;\n-\tv4l2ExtCtrls.controls = v4l2Ctrls;\n-\tv4l2ExtCtrls.count = count;\n+\tv4l2ExtCtrls.controls = v4l2Ctrls.data();\n+\tv4l2ExtCtrls.count = v4l2Ctrls.size();\n \n \tint ret = ioctl(VIDIOC_G_EXT_CTRLS, &v4l2ExtCtrls);\n \tif (ret) {\n \t\tunsigned int errorIdx = v4l2ExtCtrls.error_idx;\n \n \t\t/* Generic validation error. */\n-\t\tif (errorIdx == 0 || errorIdx >= count) {\n+\t\tif (errorIdx == 0 || errorIdx >= v4l2Ctrls.size()) {\n \t\t\tLOG(V4L2, Error) << \"Unable to read controls: \"\n \t\t\t\t\t << strerror(-ret);\n \t\t\treturn {};\n@@ -250,10 +249,11 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n \t\t/* A specific control failed. */\n \t\tLOG(V4L2, Error) << \"Unable to read control \" << errorIdx\n \t\t\t\t << \": \" << strerror(-ret);\n-\t\tcount = errorIdx - 1;\n+\n+\t\tv4l2Ctrls.resize(errorIdx);\n \t}\n \n-\tupdateControls(&ctrls, v4l2Ctrls, count);\n+\tupdateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size());\n \n \treturn ctrls;\n }\n", "prefixes": [ "libcamera-devel", "v6", "1/3" ] }