Show a patch.

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

{
    "id": 19473,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19473/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19473/",
    "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": "<20240201050810.3501276-2-raj.khem@gmail.com>",
    "date": "2024-02-01T05:08:10",
    "name": "[2/2] options: Replace use of VLAs in C++",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "1b56fe0a491faeece46caa70751b79533d9c0ff5",
    "submitter": {
        "id": 62,
        "url": "https://patchwork.libcamera.org/api/1.1/people/62/?format=api",
        "name": "Khem Raj",
        "email": "raj.khem@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19473/mbox/",
    "series": [
        {
            "id": 4163,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4163/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4163",
            "date": "2024-02-01T05:08:09",
            "name": "[1/2] media_device: Add bool return type to unlock()",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4163/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19473/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19473/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 B44DBC32A9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  1 Feb 2024 05:08:18 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 72DFF62808;\n\tThu,  1 Feb 2024 06:08:18 +0100 (CET)",
            "from mail-ot1-x331.google.com (mail-ot1-x331.google.com\n\t[IPv6:2607:f8b0:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB86B62801\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  1 Feb 2024 06:08:15 +0100 (CET)",
            "by mail-ot1-x331.google.com with SMTP id\n\t46e09a7af769-6e1196dc31bso242073a34.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 31 Jan 2024 21:08:15 -0800 (PST)",
            "from apollo.hsd1.ca.comcast.net ([2601:646:9d80:4380::8157])\n\tby smtp.gmail.com with ESMTPSA id\n\tz1-20020aa78881000000b006ddcf451a37sm10803480pfe.75.2024.01.31.21.08.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 31 Jan 2024 21:08:13 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"NuWvAFHE\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20230601; t=1706764094; x=1707368894;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=42Vq7L+2Kae/lqnZWnj9ncsGRvaauD5Mm3MRrwUL/Jg=;\n\tb=NuWvAFHEqjvi1up/+0MTenjdhL/O3poru+OtdG9lGHnC6gn/YYFQoXD577HhxsE0vR\n\tgZOVUZGeEs+964lsJsNPOtK9Fos6FadYPUaotFTUr6gzeMTsWMe+GEB4m5ew7X1ESYO5\n\tT3agkweXfITgI/pR6xIRsjIWQ3l2wsJhzcnbhwN97LtHIoiGG9Fjyz8lNP3q609HdsaE\n\t0WmWZoijWbtSNW7QwtcQbgagzoevWhkVxG+82wOdTEDC3KyuyY0NLkOf0Ewv6lUwAOyA\n\ttq52ejvlfYUAUOgaVE/u6Dx2vvS92a69rBtj9luUuaLIGVdCzk2bjbNsowa+zi9+J6yZ\n\tIWGQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1706764094; x=1707368894;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=42Vq7L+2Kae/lqnZWnj9ncsGRvaauD5Mm3MRrwUL/Jg=;\n\tb=eFAjg6777OR0JEcrfhQj1JDbXcRkPPkOgZIWQd6ouAR53MgjXLg5rAsw9eS50MEg0w\n\txSIYSJILd3NpzAJEw5IpURqARxi/Eo8VyU3UXUwdbWG+NSb2JjBYg6Jg35ykhJnUfNHI\n\tVWCojfA3cEcC2i+RPuB4oC4B5wD0F/sW5T6pUA47+0ACL661pRjbO6L67LXMpeMaLvYN\n\tKF4h5HiInmvGeq5jSyfhrOAHlelRA7NAuP8bTxVtYpMlUXzwnMPzZzA2Pa/i5gD1SpOA\n\tqhRJ2jzAdajBPdM2Xv8WkYmid5qWhSMX9o4No7rPHQY5zIYlU9S6hrHUcbYkaHqyhkMP\n\tXD8g==",
        "X-Gm-Message-State": "AOJu0YzRjr6Rd2ogMzS/qsQltxLq4JKmNgIIRq6chHdO6Ay8zk6xzXbD\n\tTxghfUUp5e/CSQqd/u4X5+AvznpaLI2inB2sJZGh/hE51yOaUdukGbUFhuT/6tM=",
        "X-Google-Smtp-Source": "AGHT+IEb9yGmocRB4GmRSD2ksovfEemJrQ/eEtRriuNlohi4C4HF/v5d3qu+MC3VVbdwcRpm7q/q6Q==",
        "X-Received": "by 2002:a05:6359:4206:b0:176:d5b7:344a with SMTP id\n\tkn6-20020a056359420600b00176d5b7344amr1792661rwb.29.1706764093944; \n\tWed, 31 Jan 2024 21:08:13 -0800 (PST)",
        "From": "Khem Raj <raj.khem@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH 2/2] options: Replace use of VLAs in C++",
        "Date": "Wed, 31 Jan 2024 21:08:10 -0800",
        "Message-ID": "<20240201050810.3501276-2-raj.khem@gmail.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240201050810.3501276-1-raj.khem@gmail.com>",
        "References": "<20240201050810.3501276-1-raj.khem@gmail.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>",
        "Cc": "Khem Raj <raj.khem@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Clang++ 18 is fussy about this with new warning checks.\n\n   ../git/src/apps/common/options.cpp:882:20: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]\n      882 |         char shortOptions[optionsMap_.size() * 3 + 2];\n          |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTherefore replace using VLAs with alloca and malloc/free\n\nSigned-off-by: Khem Raj <raj.khem@gmail.com>\n---\n src/apps/common/options.cpp      |  4 ++--\n src/libcamera/ipc_unixsocket.cpp | 12 ++++++++----\n 2 files changed, 10 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/src/apps/common/options.cpp b/src/apps/common/options.cpp\nindex 4f7e8691..b020f603 100644\n--- a/src/apps/common/options.cpp\n+++ b/src/apps/common/options.cpp\n@@ -879,8 +879,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)\n \t * Allocate short and long options arrays large enough to contain all\n \t * options.\n \t */\n-\tchar shortOptions[optionsMap_.size() * 3 + 2];\n-\tstruct option longOptions[optionsMap_.size() + 1];\n+\tchar *shortOptions = (char*)alloca(optionsMap_.size() * 3 + 2);\n+\tstruct option *longOptions = (struct option*)alloca(optionsMap_.size() + 1);\n \tunsigned int ids = 0;\n \tunsigned int idl = 0;\n \ndiff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp\nindex 1980d374..3a7f8ee6 100644\n--- a/src/libcamera/ipc_unixsocket.cpp\n+++ b/src/libcamera/ipc_unixsocket.cpp\n@@ -247,8 +247,8 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length,\n \tiov[0].iov_base = const_cast<void *>(buffer);\n \tiov[0].iov_len = length;\n \n-\tchar buf[CMSG_SPACE(num * sizeof(uint32_t))];\n-\tmemset(buf, 0, sizeof(buf));\n+\tchar *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t)));\n+\tmemset((void*)buf, 0, sizeof(buf));\n \n \tstruct cmsghdr *cmsg = (struct cmsghdr *)buf;\n \tcmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t));\n@@ -270,9 +270,11 @@ int IPCUnixSocket::sendData(const void *buffer, size_t length,\n \t\tint ret = -errno;\n \t\tLOG(IPCUnixSocket, Error)\n \t\t\t<< \"Failed to sendmsg: \" << strerror(-ret);\n+    free(buf);\n \t\treturn ret;\n \t}\n \n+  free(buf);\n \treturn 0;\n }\n \n@@ -283,8 +285,8 @@ int IPCUnixSocket::recvData(void *buffer, size_t length,\n \tiov[0].iov_base = buffer;\n \tiov[0].iov_len = length;\n \n-\tchar buf[CMSG_SPACE(num * sizeof(uint32_t))];\n-\tmemset(buf, 0, sizeof(buf));\n+\tchar *buf = (char*)malloc(CMSG_SPACE(num * sizeof(uint32_t)));\n+\tmemset((void*)buf, 0, sizeof(buf));\n \n \tstruct cmsghdr *cmsg = (struct cmsghdr *)buf;\n \tcmsg->cmsg_len = CMSG_LEN(num * sizeof(uint32_t));\n@@ -305,12 +307,14 @@ int IPCUnixSocket::recvData(void *buffer, size_t length,\n \t\tif (ret != -EAGAIN)\n \t\t\tLOG(IPCUnixSocket, Error)\n \t\t\t\t<< \"Failed to recvmsg: \" << strerror(-ret);\n+    free(buf);\n \t\treturn ret;\n \t}\n \n \tif (fds)\n \t\tmemcpy(fds, CMSG_DATA(cmsg), num * sizeof(uint32_t));\n \n+  free(buf);\n \treturn 0;\n }\n \n",
    "prefixes": [
        "2/2"
    ]
}