Patch Detail
Show a patch.
GET /api/patches/22910/?format=api
{ "id": 22910, "url": "https://patchwork.libcamera.org/api/patches/22910/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22910/", "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": "<20250303154844.745574-2-barnabas.pocze@ideasonboard.com>", "date": "2025-03-03T15:48:42", "name": "[v1,1/3] libcamera: base: log: Take `LogCategory` by reference", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "2d7d3333c803e06663b2f9bcf90713b9cf5be26f", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22910/mbox/", "series": [ { "id": 5037, "url": "https://patchwork.libcamera.org/api/series/5037/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5037", "date": "2025-03-03T15:48:41", "name": "libcamera: base: log: Do not instantiate disabled `LogMessage`s", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5037/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22910/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22910/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 ED6D0BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 3 Mar 2025 15:48:53 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 03594687EB;\n\tMon, 3 Mar 2025 16:48:51 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 595C168777\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Mar 2025 16:48:48 +0100 (CET)", "from pb-laptop.local (185.221.143.4.nat.pool.zt.hu [185.221.143.4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D017E8DB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Mar 2025 16:47:16 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZmyOS/dB\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741016836;\n\tbh=R4zYeWhgQ8GXqDxHddFIi9PKdM0ZVS9Hx/9PUBXa/WM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ZmyOS/dBSezu7OPNNB8cQPJV62ejHXwZkNVqOlH8Ocv1qnEymxqrJv8ZMcki59KoU\n\tz7kVBzKRXDwaDXAg7b4vDxRtJYK8AEtsIkw/6n4gKA32rQN3NBUwCu9iN7aPT5pSX+\n\tO9GDf7BaJUjItkRrUYDS+uGhdlQ2s/Gvr++D7uvE=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v1 1/3] libcamera: base: log: Take `LogCategory` by reference", "Date": "Mon, 3 Mar 2025 16:48:42 +0100", "Message-ID": "<20250303154844.745574-2-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "In-Reply-To": "<20250303154844.745574-1-barnabas.pocze@ideasonboard.com>", "References": "<20250303154844.745574-1-barnabas.pocze@ideasonboard.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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When no log category is specified, `nullptr` is passed,\nand then the `_log()` function implementations replace that\nwith `LogCategory::defaultCategory()`. But since the call site\nalways knows the log category, this condition can be removed\nand the `_LOG1()` macro can use `LogCategory::defaultCategory()`.\n\nSo remove the condition from the `_log()` implementations and\nuse references to refer to log categories.\n---\n include/libcamera/base/log.h | 8 ++++----\n src/libcamera/base/log.cpp | 8 ++++----\n 2 files changed, 8 insertions(+), 8 deletions(-)", "diff": "diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\nindex 8af74b59d..958cb488d 100644\n--- a/include/libcamera/base/log.h\n+++ b/include/libcamera/base/log.h\n@@ -96,12 +96,12 @@ public:\n protected:\n \tvirtual std::string logPrefix() const = 0;\n \n-\tLogMessage _log(const LogCategory *category, LogSeverity severity,\n+\tLogMessage _log(const LogCategory &category, LogSeverity severity,\n \t\t\tconst char *fileName = __builtin_FILE(),\n \t\t\tunsigned int line = __builtin_LINE()) const;\n };\n \n-LogMessage _log(const LogCategory *category, LogSeverity severity,\n+LogMessage _log(const LogCategory &category, LogSeverity severity,\n \t\tconst char *fileName = __builtin_FILE(),\n \t\tunsigned int line = __builtin_LINE());\n \n@@ -109,9 +109,9 @@ LogMessage _log(const LogCategory *category, LogSeverity severity,\n #define _LOG_CATEGORY(name) logCategory##name\n \n #define _LOG1(severity) \\\n-\t_log(nullptr, Log##severity).stream()\n+\t_log(LogCategory::defaultCategory(), Log##severity).stream()\n #define _LOG2(category, severity) \\\n-\t_log(&_LOG_CATEGORY(category)(), Log##severity).stream()\n+\t_log(_LOG_CATEGORY(category)(), Log##severity).stream()\n \n /*\n * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of\ndiff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 6a040b592..ba57ad8f1 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -952,11 +952,11 @@ Loggable::~Loggable()\n *\n * \\return A log message\n */\n-LogMessage Loggable::_log(const LogCategory *category, LogSeverity severity,\n+LogMessage Loggable::_log(const LogCategory &category, LogSeverity severity,\n \t\t\t const char *fileName, unsigned int line) const\n {\n \treturn LogMessage(fileName, line,\n-\t\t\t category ? *category : LogCategory::defaultCategory(),\n+\t\t\t category,\n \t\t\t severity, logPrefix());\n }\n \n@@ -972,11 +972,11 @@ LogMessage Loggable::_log(const LogCategory *category, LogSeverity severity,\n *\n * \\return A log message\n */\n-LogMessage _log(const LogCategory *category, LogSeverity severity,\n+LogMessage _log(const LogCategory &category, LogSeverity severity,\n \t\tconst char *fileName, unsigned int line)\n {\n \treturn LogMessage(fileName, line,\n-\t\t\t category ? *category : LogCategory::defaultCategory(),\n+\t\t\t category,\n \t\t\t severity);\n }\n \n", "prefixes": [ "v1", "1/3" ] }