[{"id":38778,"web_url":"https://patchwork.libcamera.org/comment/38778/","msgid":"<20260507140536.GJ1938994@killaraus.ideasonboard.com>","date":"2026-05-07T14:05:36","subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabás,\n\nThank you for the patch.\n\nOn Thu, May 07, 2026 at 03:50:18PM +0200, Barnabás Pőcze wrote:\n> When a fatal log message is used, it is expected that it will be displayed\n> and will in some way abort the execution. Since the log level of each\n> message is known at compile time, the log level check can be short-circuited\n> if a fatal message is intended.\n> \n> This also essentially reverts 2318a2863baa (\"libcamera: base: log: Inline `LOG()` into `ASSERT()`\")\n> as there is no need to inline the `_log()` calls to avoid the runtime condition.\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  include/libcamera/base/log.h | 30 +++++++++++++++++++++---------\n>  1 file changed, 21 insertions(+), 9 deletions(-)\n> \n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index 0751387a4..5cb14311e 100644\n> --- a/include/libcamera/base/log.h\n> +++ b/include/libcamera/base/log.h\n> @@ -108,10 +108,22 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n>  #ifndef __DOXYGEN__\n>  #define _LOG_CATEGORY(name) logCategory##name\n>  \n> -#define _LOG(cat, sev)                                                 \\\n> -\tswitch (const auto &_logCategory = (cat);                      \\\n> -\t\tstatic_cast<int>(_logCategory.severity() <= Log##sev)) \\\n> -\tcase 1:                                                        \\\n> +/* Returns `int` to avoid `-Wswitch-bool` below. */\n> +template<LogSeverity Severity>\n> +constexpr int isLogSeverityEnabled(const LogCategory &category)\n> +{\n> +\tstatic_assert(LogDebug <= Severity && Severity <= LogFatal);\n> +\n> +\tif constexpr (Severity < LogFatal)\n> +\t\treturn static_cast<unsigned int>(category.severity()) <= Severity;\n> +\telse\n> +\t\treturn true;\n> +}\n> +\n> +#define _LOG(cat, sev)                                        \\\n> +\tswitch (const auto &_logCategory = (cat);             \\\n> +\t\tisLogSeverityEnabled<Log##sev>(_logCategory)) \\\n> +\tcase 1:                                               \\\n>  \t\t_log(_logCategory, Log##sev).stream()\n>  \n>  #define _LOG1(severity) \\\n> @@ -130,11 +142,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n>  #endif /* __DOXYGEN__ */\n>  \n>  #ifndef NDEBUG\n> -#define ASSERT(condition) static_cast<void>(({                          \\\n> -\tif (!(condition))                                               \\\n> -\t\t_log(LogCategory::defaultCategory(), LogFatal).stream() \\\n> -\t\t\t<< \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n> -\t\t\t<< __func__ << \"()\";                            \\\n> +#define ASSERT(condition) static_cast<void>(({                       \\\n> +\tif (!(condition))                                            \\\n> +\t\tLOG(Fatal)                                           \\\n> +\t\t\t<< \"assertion \\\"\" #condition \"\\\" failed in \" \\\n> +\t\t\t<< __func__ << \"()\";                         \\\n>  }))\n>  #else\n>  #define ASSERT(condition) static_cast<void>(false && (condition))","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 EB5A4BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 May 2026 14:05:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A288563022;\n\tThu,  7 May 2026 16:05:38 +0200 (CEST)","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 B7CCC62FE1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 May 2026 16:05:37 +0200 (CEST)","from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C9D71253;\n\tThu,  7 May 2026 16:05:33 +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=\"gROCqUHu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778162733;\n\tbh=q2kDiNw0pNkcl7fBn5EvTmxUuKo8VMUDQqyc+Ikmr8I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gROCqUHuU+3HbNPsP0VQ/gpXntrrCypoo/bzFuwaXy+qhCfLN0yDxgYCIx+vcNxf9\n\tLKNatDLCRvX8AS1x7MtL1oKggfcr/VwZziU8VP7Y+jNngeFGAruJQVgP7WaVQ3myiq\n\tS/WyM61p5pclISvQtSa8j+u9gVLaFOWgKaR3deig=","Date":"Thu, 7 May 2026 17:05:36 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","Message-ID":"<20260507140536.GJ1938994@killaraus.ideasonboard.com>","References":"<20260507135019.231615-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20260507135019.231615-1-barnabas.pocze@ideasonboard.com>","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>"}},{"id":38781,"web_url":"https://patchwork.libcamera.org/comment/38781/","msgid":"<d230e582-0908-4bf6-bf80-24904dd7fd98@ideasonboard.com>","date":"2026-05-07T14:25:16","subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 05. 07. 16:05 keltezéssel, Laurent Pinchart írta:\n> Hi Barnabás,\n> \n> Thank you for the patch.\n\nIf my mail client is not lying, then there is no content after this.\nWas that intentional?\n\n\n> \n> On Thu, May 07, 2026 at 03:50:18PM +0200, Barnabás Pőcze wrote:\n>> When a fatal log message is used, it is expected that it will be displayed\n>> and will in some way abort the execution. Since the log level of each\n>> message is known at compile time, the log level check can be short-circuited\n>> if a fatal message is intended.\n>>\n>> This also essentially reverts 2318a2863baa (\"libcamera: base: log: Inline `LOG()` into `ASSERT()`\")\n>> as there is no need to inline the `_log()` calls to avoid the runtime condition.\n>>\n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> ---\n>>   include/libcamera/base/log.h | 30 +++++++++++++++++++++---------\n>>   1 file changed, 21 insertions(+), 9 deletions(-)\n>>\n>> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n>> index 0751387a4..5cb14311e 100644\n>> --- a/include/libcamera/base/log.h\n>> +++ b/include/libcamera/base/log.h\n>> @@ -108,10 +108,22 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n>>   #ifndef __DOXYGEN__\n>>   #define _LOG_CATEGORY(name) logCategory##name\n>>   \n>> -#define _LOG(cat, sev)                                                 \\\n>> -\tswitch (const auto &_logCategory = (cat);                      \\\n>> -\t\tstatic_cast<int>(_logCategory.severity() <= Log##sev)) \\\n>> -\tcase 1:                                                        \\\n>> +/* Returns `int` to avoid `-Wswitch-bool` below. */\n>> +template<LogSeverity Severity>\n>> +constexpr int isLogSeverityEnabled(const LogCategory &category)\n>> +{\n>> +\tstatic_assert(LogDebug <= Severity && Severity <= LogFatal);\n>> +\n>> +\tif constexpr (Severity < LogFatal)\n>> +\t\treturn static_cast<unsigned int>(category.severity()) <= Severity;\n>> +\telse\n>> +\t\treturn true;\n>> +}\n>> +\n>> +#define _LOG(cat, sev)                                        \\\n>> +\tswitch (const auto &_logCategory = (cat);             \\\n>> +\t\tisLogSeverityEnabled<Log##sev>(_logCategory)) \\\n>> +\tcase 1:                                               \\\n>>   \t\t_log(_logCategory, Log##sev).stream()\n>>   \n>>   #define _LOG1(severity) \\\n>> @@ -130,11 +142,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n>>   #endif /* __DOXYGEN__ */\n>>   \n>>   #ifndef NDEBUG\n>> -#define ASSERT(condition) static_cast<void>(({                          \\\n>> -\tif (!(condition))                                               \\\n>> -\t\t_log(LogCategory::defaultCategory(), LogFatal).stream() \\\n>> -\t\t\t<< \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n>> -\t\t\t<< __func__ << \"()\";                            \\\n>> +#define ASSERT(condition) static_cast<void>(({                       \\\n>> +\tif (!(condition))                                            \\\n>> +\t\tLOG(Fatal)                                           \\\n>> +\t\t\t<< \"assertion \\\"\" #condition \"\\\" failed in \" \\\n>> +\t\t\t<< __func__ << \"()\";                         \\\n>>   }))\n>>   #else\n>>   #define ASSERT(condition) static_cast<void>(false && (condition))\n>","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 E685DBDCB5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 May 2026 14:25:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F3F0E63020;\n\tThu,  7 May 2026 16:25:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30A5B62010\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 May 2026 16:25:20 +0200 (CEST)","from [192.168.33.83] (185.221.140.217.nat.pool.zt.hu\n\t[185.221.140.217])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CAF83664;\n\tThu,  7 May 2026 16:25:15 +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=\"qDj2msRf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778163915;\n\tbh=JmrInew7t+/69t7dVNRKNruwQx/RQF26TzyY7WOU2Vw=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=qDj2msRf9iEuQSu94bdwOc3DZPzTR7xTa9YVvJN0Wy1eeNGdlyDsnDk6pUXIvi54g\n\t0jznTTCHapHPPgzUmZZwBlMg6cfEnJGY7C3RFzxFl4PdZvYinAFYUzr9lXKD0W1qD/\n\tgB+axYveXdaTHJH69RdmWxlaHnFUweB+IjCATM20=","Message-ID":"<d230e582-0908-4bf6-bf80-24904dd7fd98@ideasonboard.com>","Date":"Thu, 7 May 2026 16:25:16 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20260507135019.231615-1-barnabas.pocze@ideasonboard.com>\n\t<20260507140536.GJ1938994@killaraus.ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260507140536.GJ1938994@killaraus.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":38784,"web_url":"https://patchwork.libcamera.org/comment/38784/","msgid":"<20260507143122.GL1938994@killaraus.ideasonboard.com>","date":"2026-05-07T14:31:22","subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, May 07, 2026 at 04:25:16PM +0200, Barnabás Pőcze wrote:\n> 2026. 05. 07. 16:05 keltezéssel, Laurent Pinchart írta:\n> > Hi Barnabás,\n> > \n> > Thank you for the patch.\n> \n> If my mail client is not lying, then there is no content after this.\n> Was that intentional?\n\nNot at all. I think I was so mesmerized by the code that I forgot to add\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > On Thu, May 07, 2026 at 03:50:18PM +0200, Barnabás Pőcze wrote:\n> >> When a fatal log message is used, it is expected that it will be displayed\n> >> and will in some way abort the execution. Since the log level of each\n> >> message is known at compile time, the log level check can be short-circuited\n> >> if a fatal message is intended.\n> >>\n> >> This also essentially reverts 2318a2863baa (\"libcamera: base: log: Inline `LOG()` into `ASSERT()`\")\n> >> as there is no need to inline the `_log()` calls to avoid the runtime condition.\n> >>\n> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >> ---\n> >>   include/libcamera/base/log.h | 30 +++++++++++++++++++++---------\n> >>   1 file changed, 21 insertions(+), 9 deletions(-)\n> >>\n> >> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> >> index 0751387a4..5cb14311e 100644\n> >> --- a/include/libcamera/base/log.h\n> >> +++ b/include/libcamera/base/log.h\n> >> @@ -108,10 +108,22 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n> >>   #ifndef __DOXYGEN__\n> >>   #define _LOG_CATEGORY(name) logCategory##name\n> >>   \n> >> -#define _LOG(cat, sev)                                                 \\\n> >> -\tswitch (const auto &_logCategory = (cat);                      \\\n> >> -\t\tstatic_cast<int>(_logCategory.severity() <= Log##sev)) \\\n> >> -\tcase 1:                                                        \\\n> >> +/* Returns `int` to avoid `-Wswitch-bool` below. */\n> >> +template<LogSeverity Severity>\n> >> +constexpr int isLogSeverityEnabled(const LogCategory &category)\n> >> +{\n> >> +\tstatic_assert(LogDebug <= Severity && Severity <= LogFatal);\n> >> +\n> >> +\tif constexpr (Severity < LogFatal)\n> >> +\t\treturn static_cast<unsigned int>(category.severity()) <= Severity;\n> >> +\telse\n> >> +\t\treturn true;\n> >> +}\n> >> +\n> >> +#define _LOG(cat, sev)                                        \\\n> >> +\tswitch (const auto &_logCategory = (cat);             \\\n> >> +\t\tisLogSeverityEnabled<Log##sev>(_logCategory)) \\\n> >> +\tcase 1:                                               \\\n> >>   \t\t_log(_logCategory, Log##sev).stream()\n> >>   \n> >>   #define _LOG1(severity) \\\n> >> @@ -130,11 +142,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n> >>   #endif /* __DOXYGEN__ */\n> >>   \n> >>   #ifndef NDEBUG\n> >> -#define ASSERT(condition) static_cast<void>(({                          \\\n> >> -\tif (!(condition))                                               \\\n> >> -\t\t_log(LogCategory::defaultCategory(), LogFatal).stream() \\\n> >> -\t\t\t<< \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n> >> -\t\t\t<< __func__ << \"()\";                            \\\n> >> +#define ASSERT(condition) static_cast<void>(({                       \\\n> >> +\tif (!(condition))                                            \\\n> >> +\t\tLOG(Fatal)                                           \\\n> >> +\t\t\t<< \"assertion \\\"\" #condition \"\\\" failed in \" \\\n> >> +\t\t\t<< __func__ << \"()\";                         \\\n> >>   }))\n> >>   #else\n> >>   #define ASSERT(condition) static_cast<void>(false && (condition))\n> >","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 BE9A9BDCB5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 May 2026 14:31:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6E8263020;\n\tThu,  7 May 2026 16:31:25 +0200 (CEST)","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 37EE062FEC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 May 2026 16:31:24 +0200 (CEST)","from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CC97F664;\n\tThu,  7 May 2026 16:31:19 +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=\"j9abi7Dz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778164280;\n\tbh=0jKDGDFWToB7wpEjWSJuhpYCrMMn3R0hviNGlNsfNIo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=j9abi7DzudPGV11u9YPC13SlLw4ToRMyGhG2lsWntqSQSDOCRENaKJbAJzk6kxuAA\n\t8wHpz7MDi7ZuXGqM+lymL1L/NptUlAU0Hu1FW/fGbmiVge42wQ+QRP6eVbJ2XuOXHz\n\tOqbhPP/fxuYXjHqsqPBeiKCuSghlGp+W/F5GLj6Q=","Date":"Thu, 7 May 2026 17:31:22 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","Message-ID":"<20260507143122.GL1938994@killaraus.ideasonboard.com>","References":"<20260507135019.231615-1-barnabas.pocze@ideasonboard.com>\n\t<20260507140536.GJ1938994@killaraus.ideasonboard.com>\n\t<d230e582-0908-4bf6-bf80-24904dd7fd98@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<d230e582-0908-4bf6-bf80-24904dd7fd98@ideasonboard.com>","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>"}},{"id":39027,"web_url":"https://patchwork.libcamera.org/comment/39027/","msgid":"<178112663905.2116781.5503839287710760795@ping.linuxembedded.co.uk>","date":"2026-06-10T21:23:59","subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2026-05-07 15:31:22)\n> On Thu, May 07, 2026 at 04:25:16PM +0200, Barnabás Pőcze wrote:\n> > 2026. 05. 07. 16:05 keltezéssel, Laurent Pinchart írta:\n> > > Hi Barnabás,\n> > > \n> > > Thank you for the patch.\n> > \n> > If my mail client is not lying, then there is no content after this.\n> > Was that intentional?\n> \n> Not at all. I think I was so mesmerized by the code that I forgot to add\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n\nIf the CI is happy, I am.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> > > On Thu, May 07, 2026 at 03:50:18PM +0200, Barnabás Pőcze wrote:\n> > >> When a fatal log message is used, it is expected that it will be displayed\n> > >> and will in some way abort the execution. Since the log level of each\n> > >> message is known at compile time, the log level check can be short-circuited\n> > >> if a fatal message is intended.\n> > >>\n> > >> This also essentially reverts 2318a2863baa (\"libcamera: base: log: Inline `LOG()` into `ASSERT()`\")\n> > >> as there is no need to inline the `_log()` calls to avoid the runtime condition.\n> > >>\n> > >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> > >> ---\n> > >>   include/libcamera/base/log.h | 30 +++++++++++++++++++++---------\n> > >>   1 file changed, 21 insertions(+), 9 deletions(-)\n> > >>\n> > >> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> > >> index 0751387a4..5cb14311e 100644\n> > >> --- a/include/libcamera/base/log.h\n> > >> +++ b/include/libcamera/base/log.h\n> > >> @@ -108,10 +108,22 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n> > >>   #ifndef __DOXYGEN__\n> > >>   #define _LOG_CATEGORY(name) logCategory##name\n> > >>   \n> > >> -#define _LOG(cat, sev)                                                 \\\n> > >> -  switch (const auto &_logCategory = (cat);                      \\\n> > >> -          static_cast<int>(_logCategory.severity() <= Log##sev)) \\\n> > >> -  case 1:                                                        \\\n> > >> +/* Returns `int` to avoid `-Wswitch-bool` below. */\n> > >> +template<LogSeverity Severity>\n> > >> +constexpr int isLogSeverityEnabled(const LogCategory &category)\n> > >> +{\n> > >> +  static_assert(LogDebug <= Severity && Severity <= LogFatal);\n> > >> +\n> > >> +  if constexpr (Severity < LogFatal)\n> > >> +          return static_cast<unsigned int>(category.severity()) <= Severity;\n> > >> +  else\n> > >> +          return true;\n> > >> +}\n> > >> +\n> > >> +#define _LOG(cat, sev)                                        \\\n> > >> +  switch (const auto &_logCategory = (cat);             \\\n> > >> +          isLogSeverityEnabled<Log##sev>(_logCategory)) \\\n> > >> +  case 1:                                               \\\n> > >>            _log(_logCategory, Log##sev).stream()\n> > >>   \n> > >>   #define _LOG1(severity) \\\n> > >> @@ -130,11 +142,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n> > >>   #endif /* __DOXYGEN__ */\n> > >>   \n> > >>   #ifndef NDEBUG\n> > >> -#define ASSERT(condition) static_cast<void>(({                          \\\n> > >> -  if (!(condition))                                               \\\n> > >> -          _log(LogCategory::defaultCategory(), LogFatal).stream() \\\n> > >> -                  << \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n> > >> -                  << __func__ << \"()\";                            \\\n> > >> +#define ASSERT(condition) static_cast<void>(({                       \\\n> > >> +  if (!(condition))                                            \\\n> > >> +          LOG(Fatal)                                           \\\n> > >> +                  << \"assertion \\\"\" #condition \"\\\" failed in \" \\\n> > >> +                  << __func__ << \"()\";                         \\\n> > >>   }))\n> > >>   #else\n> > >>   #define ASSERT(condition) static_cast<void>(false && (condition))\n> > >\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 21230C328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Jun 2026 21:24:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1232261F06;\n\tWed, 10 Jun 2026 23:24:03 +0200 (CEST)","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 E4D6D61754\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jun 2026 23:24:01 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 776746DF;\n\tWed, 10 Jun 2026 23:23:32 +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=\"COGX8ZzI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1781126612;\n\tbh=yNOzbFcyqsv1ib37yT8O1macj2Pq9+IaWtlu8qCHU+0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=COGX8ZzIjshFw2aQSTjlVaA4FQPqRkEr/yPHG4BySiqHNG4X3CkW5QCUnDf5gC2og\n\tRbmKnb/QQLm2nWa8UqCzP3rKCwvp2B+JX4cnsI2DHIgHf6H1n/30e5QeckF4HxRJYL\n\tgIjALI+lRt36TNumDukpbv/Sc935mBW4IHxK1Bz0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260507143122.GL1938994@killaraus.ideasonboard.com>","References":"<20260507135019.231615-1-barnabas.pocze@ideasonboard.com>\n\t<20260507140536.GJ1938994@killaraus.ideasonboard.com>\n\t<d230e582-0908-4bf6-bf80-24904dd7fd98@ideasonboard.com>\n\t<20260507143122.GL1938994@killaraus.ideasonboard.com>","Subject":"Re: [PATCH v1 1/2] libcamera: base: log: Remove log level check for\n\t\"Fatal\" messages","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Wed, 10 Jun 2026 22:23:59 +0100","Message-ID":"<178112663905.2116781.5503839287710760795@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]