Show a patch.

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

{
    "id": 22878,
    "url": "https://patchwork.libcamera.org/api/patches/22878/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22878/",
    "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": "<20250225173531.2595922-9-pobrn@protonmail.com>",
    "date": "2025-02-25T17:36:22",
    "name": "[v4,8/8] libcamera: base: log: Avoid manual `LogCategory` deletion",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0d40629255419882fd64c1dcda4941a03a916c72",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22878/mbox/",
    "series": [
        {
            "id": 5022,
            "url": "https://patchwork.libcamera.org/api/series/5022/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5022",
            "date": "2025-02-25T17:35:34",
            "name": "libcamera: base: log: Misc. changes",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/5022/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22878/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22878/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 E05D5BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Feb 2025 17:36:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9BEF66873C;\n\tTue, 25 Feb 2025 18:36:29 +0100 (CET)",
            "from mail-10630.protonmail.ch (mail-10630.protonmail.ch\n\t[79.135.106.30])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3667368725\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Feb 2025 18:36:27 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"Y5MWTuey\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1740504986; x=1740764186;\n\tbh=Ub0xATXAZom6FXNmQZ3DrfsR/hgEl3RCjniWHGgBM7Q=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=Y5MWTueyqNKkgW7mEGagWxHvMdfWqZUkv8b1Eqe0fWh9oDlVWL6sxKxk7LtC8R5eM\n\tlX8XFyL009rxTxtyltnFtYnwenWTusIN0B1tjjTufa0ynaF07UQ9ZQboKwAAPso5ih\n\tow+Bf+QqvPFJJCn/fXww96J/QuVmKI35w1y8UhutGQv91mb9KTbMuRZS1p8s+KR+cp\n\td5nAWQnv+invpmh7q/ZU4zHcD4NTHdvprURZ/J0Q1Mmf9jjWAwAlR8jhkj4eVyaGd/\n\t0UbMl2VfFh+fPkjyrwNxkyJxWqlvmGfvzrUPbHsWkkb9yqDb/ZPBl9HAQEsEu2Kymg\n\tDWUH3sSME5PDA==",
        "Date": "Tue, 25 Feb 2025 17:36:22 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Cc": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Subject": "[PATCH v4 8/8] libcamera: base: log: Avoid manual `LogCategory`\n\tdeletion",
        "Message-ID": "<20250225173531.2595922-9-pobrn@protonmail.com>",
        "In-Reply-To": "<20250225173531.2595922-1-pobrn@protonmail.com>",
        "References": "<20250225173531.2595922-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "985a84bd74ef8a2b5ae65e0368901862f7a0a068",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=utf-8",
        "Content-Transfer-Encoding": "quoted-printable",
        "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": "Wrap the `LogCategory` pointers in `std::unique_ptr` to avoid\nthe need for manual deletion in the destructor.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/base/log.cpp | 13 +++++--------\n 1 file changed, 5 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 155355f0c..72614eeb1 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -322,7 +322,7 @@ private:\n \tstatic bool destroyed_;\n \n \tMutex mutex_;\n-\tstd::vector<LogCategory *> categories_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n+\tstd::vector<std::unique_ptr<LogCategory>> categories_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n \tstd::list<std::pair<std::string, LogSeverity>> levels_;\n \n \tstd::shared_ptr<LogOutput> output_;\n@@ -439,9 +439,6 @@ void logSetLevel(const char *category, const char *level)\n Logger::~Logger()\n {\n \tdestroyed_ = true;\n-\n-\tfor (LogCategory *category : categories_)\n-\t\tdelete category;\n }\n \n /**\n@@ -574,7 +571,7 @@ void Logger::logSetLevel(const char *category, const char *level)\n \n \tMutexLocker locker(mutex_);\n \n-\tfor (LogCategory *c : categories_) {\n+\tfor (const auto &c : categories_) {\n \t\tif (c->name() == category) {\n \t\t\tc->setSeverity(severity);\n \t\t\tbreak;\n@@ -718,12 +715,12 @@ LogCategory *Logger::findOrCreateCategory(std::string_view name)\n {\n \tMutexLocker locker(mutex_);\n \n-\tfor (LogCategory *category : categories_) {\n+\tfor (const auto &category : categories_) {\n \t\tif (category->name() == name)\n-\t\t\treturn category;\n+\t\t\treturn category.get();\n \t}\n \n-\tLogCategory *category = categories_.emplace_back(new LogCategory(name));\n+\tLogCategory *category = categories_.emplace_back(std::unique_ptr<LogCategory>(new LogCategory(name))).get();\n \tconst char *categoryName = category->name().c_str();\n \n \tfor (const auto &[pattern, severity] : levels_) {\n",
    "prefixes": [
        "v4",
        "8/8"
    ]
}