Cover Letter Detail
Show a cover letter.
GET /api/covers/12298/?format=api
{ "id": 12298, "url": "https://patchwork.libcamera.org/api/covers/12298/?format=api", "web_url": "https://patchwork.libcamera.org/cover/12298/", "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": "<20210515040511.23294-1-laurent.pinchart@ideasonboard.com>", "date": "2021-05-15T04:05:07", "name": "[libcamera-devel,v2,0/4] libcamera: Simplify range-based for loop counters", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/cover/12298/mbox/", "series": [ { "id": 2032, "url": "https://patchwork.libcamera.org/api/series/2032/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2032", "date": "2021-05-15T04:05:07", "name": "libcamera: Simplify range-based for loop counters", "version": 2, "mbox": "https://patchwork.libcamera.org/series/2032/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/covers/12298/comments/", "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 EF81DC31F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 15 May 2021 04:05:26 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 54E6A6891B;\n\tSat, 15 May 2021 06:05:26 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C84C6602B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 15 May 2021 06:05:24 +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 C7F3C6EE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 15 May 2021 06:05:23 +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=\"GZYCEBJR\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621051523;\n\tbh=JSywPDHgP+6LbEptXbuENmskKBy3+SuD9uN2eHHuO9E=;\n\th=From:To:Subject:Date:From;\n\tb=GZYCEBJRzytbursSq3Q5mnh70lmPOyxtFjzUZCSVLaS4mwAydC6SyCz5PF8m+gdIn\n\tWosasKJNPg+jNbFEalONgrzapLQYMHf27aTmoXHe1f8KaM+NC/PJbWeK8AL3MvgjTW\n\tIYwYlVGvPfgwV0mjkF+iCk2FFf6hEPmRik2mVMWQ=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 15 May 2021 07:05:07 +0300", "Message-Id": "<20210515040511.23294-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.28.1", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 0/4] libcamera: Simplify range-based\n\tfor loop counters", "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": "Hello,\n\nThis patch series simplifies for loops that iterate over a range and\nrequire a loop counter. v1 was sent as an RFC, and as it was positively\nreceived, v2 graduates to a normal series.\n\nThe limitation of the range-based for loop is explained in patch 1/4,\nwhich provides a new utils::enumerate() function to solve the problem.\nThe API is inspired by the C++23 views::enumerate proposal\n(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2164r1.pdf),\nbut implemented without the range library as that's a C++20 feature.\n\nPatch 2/4 is an example of how code can be simplified. It also outlines\na limitation of the API. Due to the C++ lifetime rules, we can't safely\npass a temporary to utils::enumerate() as the temporary would be\ndestroyed once utils::enumerate() returns but before the for loop\ncompletes (actually before it even starts), resulting in use-after-free\nerrors. The issue is explained in more details in\nhttp://josuttis.com/download/std/D2012R0_fix_rangebasedfor_201029.pdf.\nThe ensure that such bugs can't be introduced by mistake, the\nutils::enumerate() function takes an lvalue reference only. The drawback\nis that a loop that iterates over a temporary must now stores that\ntemporary in a named variable before the loop. On a side note, C++20\nwould bring us a workaround to declare that variable within the loop\nstatement. If anyone can think of a clever idea to fix this problem, I'm\nall ears. One option may be to store a copy of the iterable in the\nadapter when utils::enumerate() is given an rvalue, possibly with move\nsemantics, but it may still be costly in some cases, I'm not sure how\ncompilers would optimize that.\n\nPatch 3/4 provides an alternative API that uses an aggregate with named\nfields instead of an std::pair with structured binding, with patch 4/4\nadapting the example for 2/4 accordingly. There seems to be a preference\nfor the structured bindings, which means that 3/4 and 4/4 are likely to\nbe dropped. If they however end up being accepted after changes of mind,\nI'll squash them with 1/4 and 2/4 respectively.\n\nLaurent Pinchart (4):\n libcamera: utils: Add enumerate view for range-based for loops\n v4l2: Replace manual loop counters with utils::enumerate()\n libcamera: utils: enumerate: Use named fields for result\n v4l2: Adapt to utils::enumerate() usage of named fields\n\n include/libcamera/internal/utils.h | 92 ++++++++++++++++++++++++++++++\n src/libcamera/utils.cpp | 30 ++++++++++\n src/v4l2/v4l2_compat_manager.cpp | 18 +++---\n test/utils.cpp | 59 +++++++++++++++++++\n 4 files changed, 190 insertions(+), 9 deletions(-)" }