From patchwork Mon Jan 19 11:30:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25846 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5A5A7BDCBF for ; Mon, 19 Jan 2026 11:31:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 257F361FCA; Mon, 19 Jan 2026 12:31:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="r7RmNY6r"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 09E5B61FA3 for ; Mon, 19 Jan 2026 12:31:08 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7D473BE1; Mon, 19 Jan 2026 12:30:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768822237; bh=1quctgwdm0tnkABtF3rnkSIUDkcXlbJUKHu3rmdpEic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r7RmNY6rZkvWNLA2osIZaHnDYex1O6SrUlpvRTSWdK3tClL6qD4us7OvYgdYHUIT5 ylDuFWrjJv5Fwc8G8ijEjO6lHtEzYb30Oceupb5mQOga3PMx6WvDj59ggGithTOvCS ATCE6rZBivh7Ea2BuRPBuVQqChpHg/sdgoW8rDeo= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Laurent Pinchart , Kieran Bingham Subject: [PATCH v2 1/5] treewide: Remove `libcamera::LOG(...)` occurrences Date: Mon, 19 Jan 2026 12:30:59 +0100 Message-ID: <20260119113104.3560802-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> References: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When a class inherits from `Loggable`, it will have a protected `_log()` function and that will be used instead of the global `_log()` function in the expansion of the `LOG()` macro. However, if such a class has static member functions, then simply writing `LOG()` will not work because name lookup will find the non-static member function and no the global function, resulting in a compiler error because the non-static member cannot be invoked without an object, and there is no object in a static member function. This can be avoided by using `using libcamera::_log;`, thereby bringing the global declaration into the current scope. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/sensor/camera_sensor_raw.cpp | 8 +++++--- src/libcamera/v4l2_device.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 759cccafe..81d8985ee 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -172,10 +172,12 @@ CameraSensorRaw::~CameraSensorRaw() = default; std::variant, int> CameraSensorRaw::match(MediaEntity *entity) { + using libcamera::_log; + /* Check the entity type. */ if (entity->type() != MediaEntity::Type::V4L2Subdevice || entity->function() != MEDIA_ENT_F_CAM_SENSOR) { - libcamera::LOG(CameraSensor, Debug) + LOG(CameraSensor, Debug) << entity->name() << ": unsupported entity type (" << utils::to_underlying(entity->type()) << ") or function (" << utils::hex(entity->function()) << ")"; @@ -200,7 +202,7 @@ CameraSensorRaw::match(MediaEntity *entity) break; default: - libcamera::LOG(CameraSensor, Debug) + LOG(CameraSensor, Debug) << entity->name() << ": unsupported pad " << pad->index() << " type " << utils::hex(pad->flags()); return { 0 }; @@ -208,7 +210,7 @@ CameraSensorRaw::match(MediaEntity *entity) } if (numSinks < 1 || numSinks > 2 || numSources != 1) { - libcamera::LOG(CameraSensor, Debug) + LOG(CameraSensor, Debug) << entity->name() << ": unsupported number of sinks (" << numSinks << ") or sources (" << numSources << ")"; return { 0 }; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 1582c03ef..b49d73b1c 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -1032,6 +1032,8 @@ template std::optional V4L2Device::toColorSpace(const struct v4l2_mb template int V4L2Device::fromColorSpace(const std::optional &colorSpace, T &v4l2Format) { + using libcamera::_log; + v4l2Format.colorspace = V4L2_COLORSPACE_DEFAULT; v4l2Format.xfer_func = V4L2_XFER_FUNC_DEFAULT; v4l2Format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; @@ -1060,7 +1062,7 @@ int V4L2Device::fromColorSpace(const std::optional &colorSpace, T &v if (itPrimaries != primariesToV4l2.end()) { v4l2Format.colorspace = itPrimaries->second; } else { - libcamera::LOG(V4L2, Warning) + LOG(V4L2, Warning) << "Unrecognised primaries in " << ColorSpace::toString(colorSpace); ret = -EINVAL; @@ -1070,7 +1072,7 @@ int V4L2Device::fromColorSpace(const std::optional &colorSpace, T &v if (itTransfer != transferFunctionToV4l2.end()) { v4l2Format.xfer_func = itTransfer->second; } else { - libcamera::LOG(V4L2, Warning) + LOG(V4L2, Warning) << "Unrecognised transfer function in " << ColorSpace::toString(colorSpace); ret = -EINVAL; @@ -1080,7 +1082,7 @@ int V4L2Device::fromColorSpace(const std::optional &colorSpace, T &v if (itYcbcrEncoding != ycbcrEncodingToV4l2.end()) { v4l2Format.ycbcr_enc = itYcbcrEncoding->second; } else { - libcamera::LOG(V4L2, Warning) + LOG(V4L2, Warning) << "Unrecognised YCbCr encoding in " << ColorSpace::toString(colorSpace); ret = -EINVAL; @@ -1090,7 +1092,7 @@ int V4L2Device::fromColorSpace(const std::optional &colorSpace, T &v if (itRange != rangeToV4l2.end()) { v4l2Format.quantization = itRange->second; } else { - libcamera::LOG(V4L2, Warning) + LOG(V4L2, Warning) << "Unrecognised quantization in " << ColorSpace::toString(colorSpace); ret = -EINVAL; From patchwork Mon Jan 19 11:31:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25847 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D4EFEC327D for ; Mon, 19 Jan 2026 11:31:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B39F861FC6; Mon, 19 Jan 2026 12:31:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aGG5poCg"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3787961FB9 for ; Mon, 19 Jan 2026 12:31:08 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6728C79 for ; Mon, 19 Jan 2026 12:30:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768822237; bh=emvrmnnI4/cToii6BSjuUIOwHrDklh9jfJ5ZFeVMMdo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aGG5poCgpTCFE2f9YITw3QM6OmsrlA8a7sbsYpEh7oPHTGl3zhibvdWMx6AR7lPKA +XvCJOjkLKF6CbIBPWwq/Cq2DP0r6DxH+FMKAzhfDsYCRShRyo51NFvGRa9H8qMGk+ 1odfw46yQMBnLBLFiart0CTgxPu0zmPzhwi/qi/k= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 2/5] libcamera: base: log: Do not instantiate disabled `LogMessage`s Date: Mon, 19 Jan 2026 12:31:00 +0100 Message-ID: <20260119113104.3560802-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> References: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" At the moment every `LOG()` macro invocation results in a `LogMessage` being created, the message serialized into an `std::stringstream`. Only in the destructor is it actually checked whether the given `LogCategory` enables the given log level. This is not too efficient, it would be better to skip the log message construction and all the `operator<<()` invocations if the message will just be discarded. This could be easily done if the `LOG()` macro accepted its arguments like a traditional function as in that case an appropriate `if` statement can be injected in a do-while loop. However, that is not the case, the `LOG()` macro should effectively "return" a stream. It is not possible inject an `if` statement directly as that would lead to issues: if (...) LOG(...) else ... The `else` would bind the to the `if` in the `LOG()` macro. This is diagnosed by `-Wdangling-else`. An alternative approach would be to use a `for` loop and force a single iteration using a boolean flag or similar. This is entirely doable but I think the implemented approach is easier to understand. This change implements the early log level checking using a `switch` statement as this avoids the dangling else related issues. One small issue arises because having a boolean controlling expression is diagnosed by clang (`-Wswitch-bool`); the result is cast to `int` to avoid the warning. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- include/libcamera/base/log.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index d8338d8df..dbd14951c 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -108,10 +108,15 @@ LogMessage _log(const LogCategory &category, LogSeverity severity, #ifndef __DOXYGEN__ #define _LOG_CATEGORY(name) logCategory##name +#define _LOG(cat, sev) \ + switch (const auto &_logCategory = (cat); int(_logCategory.severity() <= Log##sev)) \ + case 1: \ + _log(_logCategory, Log##sev).stream() + #define _LOG1(severity) \ - _log(LogCategory::defaultCategory(), Log##severity).stream() + _LOG(LogCategory::defaultCategory(), severity) #define _LOG2(category, severity) \ - _log(_LOG_CATEGORY(category)(), Log##severity).stream() + _LOG(_LOG_CATEGORY(category)(), severity) /* * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of From patchwork Mon Jan 19 11:31:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25848 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7AC47BDCBF for ; Mon, 19 Jan 2026 11:31:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 117D261FD0; Mon, 19 Jan 2026 12:31:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LhgDa2Rl"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4EBFC61FBC for ; Mon, 19 Jan 2026 12:31:08 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E3DF52D9 for ; Mon, 19 Jan 2026 12:30:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768822238; bh=dz+PKmSwfBLDv660zSPoeRZk0ATInnynAE8KmASQLBs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LhgDa2RlNzVnI2ZDcYn4BBDpnYvDFguxA2JI71L1WHWFu5RVUIMvnGnZGb5IH1fZP 9qiGN42qPjAFg86z8/vL5E5TJRrpEzUIIb73VxO+pbjl8SjXBG/0mynML3rhwYawui h/YnQc1xWWYNgsr+yH3PPP9NS1Nnjol3D2pK2iMo= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 3/5] libcamera: base: log: Do not check severity before printing Date: Mon, 19 Jan 2026 12:31:01 +0100 Message-ID: <20260119113104.3560802-4-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> References: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Now that the severity of the log message and the category is compared in the expansion of the `LOG()` macro, there is no need to do it again in the destructor. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- src/libcamera/base/log.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 6e6d2887c..da45b0d65 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -867,8 +867,7 @@ LogMessage::~LogMessage() msgStream_ << std::endl; - if (severity_ >= category_.severity()) - logger->write(*this); + logger->write(*this); if (severity_ == LogSeverity::LogFatal) { logger->backtrace(); From patchwork Mon Jan 19 11:31:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25849 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0CD1CC32E7 for ; Mon, 19 Jan 2026 11:31:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A16B61FC5; Mon, 19 Jan 2026 12:31:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="arMcvaY5"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 62EE561FBF for ; Mon, 19 Jan 2026 12:31:08 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 24FE4C7B for ; Mon, 19 Jan 2026 12:30:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768822238; bh=SciAsgSRkrmF8HdcmTNvyPv/RmUR13NN79Xl5+b+6xQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=arMcvaY5cHk6Ux/2G9rQSi2PTH9WpMWVu5RwbBMF5JtoBxr+L/Eli2F+A8f/TYBh6 CtkBxfgD8SkL8Rn4lMMC+51waBicgOD08+5DUdwgd5DN4pyNXu01TKN/WD1j/SKJfD F2jCvKdTVQU6j8nSGeFjRDETJM9cy5LZJHVeOMBo= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 4/5] libcamera: base: log: Remove `LogInvalid` check Date: Mon, 19 Jan 2026 12:31:02 +0100 Message-ID: <20260119113104.3560802-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> References: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A `LogMessage` instance cannot be moved or copied, so a severity of `LogInvalid` is only possible if the message was constructed with that log level explicitly. However, being a completely internal type, this does not occur. So remove the check. And even if it does, it's probably still better to print the message than to drop it silently. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- src/libcamera/base/log.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index da45b0d65..7d308afae 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -857,10 +857,6 @@ LogMessage::LogMessage(const char *fileName, unsigned int line, LogMessage::~LogMessage() { - /* Don't print anything if we have been moved to another LogMessage. */ - if (severity_ == LogInvalid) - return; - Logger *logger = Logger::instance(); if (!logger) return; From patchwork Mon Jan 19 11:31:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25850 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C2F09C327D for ; Mon, 19 Jan 2026 11:31:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7903B61FCA; Mon, 19 Jan 2026 12:31:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GKHIiId4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 903E261FC0 for ; Mon, 19 Jan 2026 12:31:08 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 50A80C79 for ; Mon, 19 Jan 2026 12:30:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768822238; bh=PA3i2QUDvbgwK1eYqs0+mNuHHaAHoiKgE3WuGpC/PmE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GKHIiId4CiGYg5Tvw63+5aJOy1dI33leVFcwVWHd0MB3xpwU0Lf274HwRl2GMWDXB yskox5S92qq4ZCBzaoJdHnMgpLLTTwbnUd5pDnXPBoC5I49iCWrSKqbRXAGRvJTb0D UBg7ir6Jj4KfyfqdOi1399jYt5q7OiuwsGu9/K3M= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into `ASSERT()` Date: Mon, 19 Jan 2026 12:31:03 +0100 Message-ID: <20260119113104.3560802-6-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> References: <20260119113104.3560802-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Avoid the conditional logic in the expansion of `LOG()` inside `ASSERT()` by directly calling `_log(...)` with the appropriate parameters. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham --- include/libcamera/base/log.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index dbd14951c..8419300a5 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -130,9 +130,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity, #ifndef NDEBUG #define ASSERT(condition) static_cast(({ \ - if (!(condition)) \ - LOG(Fatal) << "assertion \"" #condition "\" failed in " \ - << __func__ << "()"; \ + if (!(condition)) { \ + _log(LogCategory::defaultCategory(), LogFatal).stream() \ + << "assertion \"" #condition "\" failed in " \ + << __func__ << "()"; \ + } \ })) #else #define ASSERT(condition) static_cast(false && (condition))