Show a patch.

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

{
    "id": 23183,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/23183/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23183/",
    "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": "<20250417113342.1137697-1-barnabas.pocze@ideasonboard.com>",
    "date": "2025-04-17T11:33:42",
    "name": "[v1] apps: cam: capture_script: Simplify bool array parsing",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0a7ee1a754a448fcd24bccf0731f86b5432fc6e5",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23183/mbox/",
    "series": [
        {
            "id": 5130,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5130/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5130",
            "date": "2025-04-17T11:33:42",
            "name": "[v1] apps: cam: capture_script: Simplify bool array parsing",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5130/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23183/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23183/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 B6B21C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Apr 2025 11:33:47 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07F8768AC2;\n\tThu, 17 Apr 2025 13:33:47 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E806617E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Apr 2025 13:33:46 +0200 (CEST)",
            "from pb-laptop.local (185.221.143.16.nat.pool.zt.hu\n\t[185.221.143.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8EBA96A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Apr 2025 13:31:42 +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=\"M9r5+afl\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1744889502;\n\tbh=dzQplmU58f6SWok+A/3JSbsXZZKlI3n5lVKByFpnhjk=;\n\th=From:To:Subject:Date:From;\n\tb=M9r5+aflAW0p9LkEIpnFbXU1Ovr8zzqXKN1xSKt0E4hlcakdW4Ew1xF3oOfqMuZZ5\n\t5IwcxobtjYDLfo69qcn8wF392haEUn4ZLejYmZtXSkoBgnEdrGJ5XvqMm1a1Tu/FdM\n\tg2KPlH0sodmzoI+37jZ44IfhXo4mvuozIMSET1JE=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v1] apps: cam: capture_script: Simplify bool array parsing",
        "Date": "Thu, 17 Apr 2025 13:33:42 +0200",
        "Message-ID": "<20250417113342.1137697-1-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.49.0",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "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": "`std::vector<bool>` is a specialization that implements a dynamic\nbit vector, therefore it is not suitable to provide storage for\nan array of `bool`. Hence a statically sized array is used when\nparsing an array of boolean values.\n\nInstead, use the array overload of `std::make_unique` since the\nsize is known beforehand.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/apps/cam/capture_script.cpp | 36 +++++++--------------------------\n 1 file changed, 7 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp\nindex 7d079721a..8ecd89f28 100644\n--- a/src/apps/cam/capture_script.cpp\n+++ b/src/apps/cam/capture_script.cpp\n@@ -8,6 +8,7 @@\n #include \"capture_script.h\"\n \n #include <iostream>\n+#include <memory>\n #include <stdio.h>\n #include <stdlib.h>\n \n@@ -521,45 +522,22 @@ ControlValue CaptureScript::parseArrayControl(const ControlId *id,\n \tcase ControlTypeNone:\n \t\tbreak;\n \tcase ControlTypeBool: {\n-\t\t/*\n-\t\t * This is unpleasant, but we cannot use an std::vector<> as its\n-\t\t * boolean type overload does not allow to access the raw data,\n-\t\t * as boolean values are stored in a bitmask for efficiency.\n-\t\t *\n-\t\t * As we need a contiguous memory region to wrap in a Span<>,\n-\t\t * use an array instead but be strict about not overflowing it\n-\t\t * by limiting the number of controls we can store.\n-\t\t *\n-\t\t * Be loud but do not fail, as the issue would present at\n-\t\t * runtime and it's not fatal.\n-\t\t */\n-\t\tstatic constexpr unsigned int kMaxNumBooleanControls = 1024;\n-\t\tstd::array<bool, kMaxNumBooleanControls> values;\n-\t\tunsigned int idx = 0;\n+\t\tauto values = std::make_unique<bool[]>(repr.size());\n \n-\t\tfor (const std::string &s : repr) {\n-\t\t\tbool val;\n+\t\tfor (std::size_t i = 0; i < repr.size(); i++) {\n+\t\t\tconst auto &s = repr[i];\n \n \t\t\tif (s == \"true\") {\n-\t\t\t\tval = true;\n+\t\t\t\tvalues[i] = true;\n \t\t\t} else if (s == \"false\") {\n-\t\t\t\tval = false;\n+\t\t\t\tvalues[i] = false;\n \t\t\t} else {\n \t\t\t\tunpackFailure(id, s);\n \t\t\t\treturn value;\n \t\t\t}\n-\n-\t\t\tif (idx == kMaxNumBooleanControls) {\n-\t\t\t\tstd::cerr << \"Cannot parse more than \"\n-\t\t\t\t\t  << kMaxNumBooleanControls\n-\t\t\t\t\t  << \" boolean controls\" << std::endl;\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\tvalues[idx++] = val;\n \t\t}\n \n-\t\tvalue = Span<bool>(values.data(), idx);\n+\t\tvalue = Span<bool>(values.get(), repr.size());\n \t\tbreak;\n \t}\n \tcase ControlTypeByte: {\n",
    "prefixes": [
        "v1"
    ]
}