[{"id":37735,"web_url":"https://patchwork.libcamera.org/comment/37735/","msgid":"<176882727192.3486172.15264525466548732776@ping.linuxembedded.co.uk>","date":"2026-01-19T12:54:31","subject":"Re: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into\n\t`ASSERT()`","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2026-01-19 11:31:03)\n> Avoid the conditional logic in the expansion of `LOG()` inside `ASSERT()` by\n> directly calling `_log(...)` with the appropriate parameters.\n> \n\nIs this just a final optimisation ? Part of me thinks LOG(Fatal) is\nnicer as that's how we handle log messages, but ... this seems\nreasonable anyway, and if it prevents a double check - well it's all\ninternal in here so:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  include/libcamera/base/log.h | 8 +++++---\n>  1 file changed, 5 insertions(+), 3 deletions(-)\n> \n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index dbd14951c..8419300a5 100644\n> --- a/include/libcamera/base/log.h\n> +++ b/include/libcamera/base/log.h\n> @@ -130,9 +130,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n>  \n>  #ifndef NDEBUG\n>  #define ASSERT(condition) static_cast<void>(({                          \\\n> -       if (!(condition))                                               \\\n> -               LOG(Fatal) << \"assertion \\\"\" #condition \"\\\" failed in \" \\\n> -                          << __func__ << \"()\";                         \\\n> +       if (!(condition)) {                                             \\\n> +               _log(LogCategory::defaultCategory(), LogFatal).stream() \\\n> +                       << \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n> +                       << __func__ << \"()\";                            \\\n> +       }                                                               \\\n>  }))\n>  #else\n>  #define ASSERT(condition) static_cast<void>(false && (condition))\n> -- \n> 2.52.0\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 811E9C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jan 2026 12:54:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C70C161FC0;\n\tMon, 19 Jan 2026 13:54:36 +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 E426461FA3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 13:54:34 +0100 (CET)","from pendragon.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 51D65B3;\n\tMon, 19 Jan 2026 13:54:04 +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=\"kvrbrmrY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768827244;\n\tbh=0Edj/897EXGNDl/DRAnaz/ar8GnpPuJ7zc8vEeSuI/I=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=kvrbrmrYd6D6TKaAOay+pW/CVsNjXiaHwOq+oSFe+mgcxCf0753kethSqbOZRmcZh\n\tEkXxu6kkxd9wYeEyGJtOrXqgzrqEx7uw6FPt49VIFf4OZAG2D3G6yFKgIJoIY/Yxv+\n\tq1GKSCo2YWlSoG7zZcPCXs/NW4XBBSOawlDkIkV0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260119113104.3560802-6-barnabas.pocze@ideasonboard.com>","References":"<20260119113104.3560802-1-barnabas.pocze@ideasonboard.com>\n\t<20260119113104.3560802-6-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into\n\t`ASSERT()`","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 19 Jan 2026 12:54:31 +0000","Message-ID":"<176882727192.3486172.15264525466548732776@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>"}},{"id":37750,"web_url":"https://patchwork.libcamera.org/comment/37750/","msgid":"<20260119175218.GH26642@pendragon.ideasonboard.com>","date":"2026-01-19T17:52:18","subject":"Re: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into\n\t`ASSERT()`","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Jan 19, 2026 at 12:54:31PM +0000, Kieran Bingham wrote:\n> Quoting Barnabás Pőcze (2026-01-19 11:31:03)\n> > Avoid the conditional logic in the expansion of `LOG()` inside `ASSERT()` by\n> > directly calling `_log(...)` with the appropriate parameters.\n> \n> Is this just a final optimisation ? Part of me thinks LOG(Fatal) is\n> nicer as that's how we handle log messages, but ... this seems\n> reasonable anyway, and if it prevents a double check - well it's all\n> internal in here so:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nI also have a slight preference for LOG(Fatal) for readability reasons,\nbut if you think this is better, I don't object.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> > ---\n> >  include/libcamera/base/log.h | 8 +++++---\n> >  1 file changed, 5 insertions(+), 3 deletions(-)\n> > \n> > diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> > index dbd14951c..8419300a5 100644\n> > --- a/include/libcamera/base/log.h\n> > +++ b/include/libcamera/base/log.h\n> > @@ -130,9 +130,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n> >  \n> >  #ifndef NDEBUG\n> >  #define ASSERT(condition) static_cast<void>(({                          \\\n> > -       if (!(condition))                                               \\\n> > -               LOG(Fatal) << \"assertion \\\"\" #condition \"\\\" failed in \" \\\n> > -                          << __func__ << \"()\";                         \\\n> > +       if (!(condition)) {                                             \\\n> > +               _log(LogCategory::defaultCategory(), LogFatal).stream() \\\n> > +                       << \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n> > +                       << __func__ << \"()\";                            \\\n> > +       }                                                               \\\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 7F1BDC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jan 2026 17:52:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B82A761FBF;\n\tMon, 19 Jan 2026 18:52:42 +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 59AA5606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 18:52:41 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 7A046C1;\n\tMon, 19 Jan 2026 18:52:10 +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=\"stF0PMd1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768845130;\n\tbh=YnMM9sktBYQ9y9Ua+QTvLsMY3OjT856vKQg5zuMSzXE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=stF0PMd1HnBF15/BSsCmTQFW13iFhXa0lJE9fqV+fevkg8Vjm4+jJQ96I7jqcUc5n\n\tyAUgP724gmqa/1HzLSc66oQ/Nt98gF+8JZgM3csA4WfcBRyDXfRsGXFPOryQVaBZzK\n\t59ZM/qo3kR6DxTnMhm7hOAGGQ+R8MTquKnL+3XYQ=","Date":"Mon, 19 Jan 2026 19:52:18 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into\n\t`ASSERT()`","Message-ID":"<20260119175218.GH26642@pendragon.ideasonboard.com>","References":"<20260119113104.3560802-1-barnabas.pocze@ideasonboard.com>\n\t<20260119113104.3560802-6-barnabas.pocze@ideasonboard.com>\n\t<176882727192.3486172.15264525466548732776@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<176882727192.3486172.15264525466548732776@ping.linuxembedded.co.uk>","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":37759,"web_url":"https://patchwork.libcamera.org/comment/37759/","msgid":"<9805b3ee-f4f6-4e28-b8fd-71bfc2b94d53@ideasonboard.com>","date":"2026-01-20T12:31:11","subject":"Re: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into\n\t`ASSERT()`","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 19. 18:52 keltezéssel, Laurent Pinchart írta:\n> On Mon, Jan 19, 2026 at 12:54:31PM +0000, Kieran Bingham wrote:\n>> Quoting Barnabás Pőcze (2026-01-19 11:31:03)\n>>> Avoid the conditional logic in the expansion of `LOG()` inside `ASSERT()` by\n>>> directly calling `_log(...)` with the appropriate parameters.\n>>\n>> Is this just a final optimisation ? Part of me thinks LOG(Fatal) is\n>> nicer as that's how we handle log messages, but ... this seems\n>> reasonable anyway, and if it prevents a double check - well it's all\n>> internal in here so:\n>>\n>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> I also have a slight preference for LOG(Fatal) for readability reasons,\n> but if you think this is better, I don't object.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n`LOG(Fatal)` indeed looks better, but I wanted to avoid the log category severity check\nin an `ASSERT()`. I had some ideas that would have allowed `LOG(Fatal)`, but I did\nnot really like either, and this change was very simple.\n\n\n> \n>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>>> ---\n>>>   include/libcamera/base/log.h | 8 +++++---\n>>>   1 file changed, 5 insertions(+), 3 deletions(-)\n>>>\n>>> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n>>> index dbd14951c..8419300a5 100644\n>>> --- a/include/libcamera/base/log.h\n>>> +++ b/include/libcamera/base/log.h\n>>> @@ -130,9 +130,11 @@ LogMessage _log(const LogCategory &category, LogSeverity severity,\n>>>   \n>>>   #ifndef NDEBUG\n>>>   #define ASSERT(condition) static_cast<void>(({                          \\\n>>> -       if (!(condition))                                               \\\n>>> -               LOG(Fatal) << \"assertion \\\"\" #condition \"\\\" failed in \" \\\n>>> -                          << __func__ << \"()\";                         \\\n>>> +       if (!(condition)) {                                             \\\n>>> +               _log(LogCategory::defaultCategory(), LogFatal).stream() \\\n>>> +                       << \"assertion \\\"\" #condition \"\\\" failed in \"    \\\n>>> +                       << __func__ << \"()\";                            \\\n>>> +       }                                                               \\\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 BD26DC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Jan 2026 12:31:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3E8FF61A35;\n\tTue, 20 Jan 2026 13:31:16 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FFE061A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jan 2026 13:31:14 +0100 (CET)","from [192.168.33.23] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D0C28177D;\n\tTue, 20 Jan 2026 13:30:42 +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=\"C9pgAcVb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768912243;\n\tbh=wCJ4zBHkrCvwB2aWtgGqUBYqCSDPsmlyhFEZwOCVK8g=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=C9pgAcVbUpz+pMe4Bx2CEG7/hGekE8Wp0SprGCnaaSS29Sli91pdnjWJ+UbceOb+y\n\tflLcpNMHyIuDF1VWazZvpO6hv7ZVMT6ak+pLXYg0z+o4UH66CsDMQQSp0e3Jk0ADea\n\t0wiZeYU6H22gYT0Lb3u77F0XImxXW/crpr4KvKCM=","Message-ID":"<9805b3ee-f4f6-4e28-b8fd-71bfc2b94d53@ideasonboard.com>","Date":"Tue, 20 Jan 2026 13:31:11 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 5/5] libcamera: base: log: Inline `LOG()` into\n\t`ASSERT()`","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20260119113104.3560802-1-barnabas.pocze@ideasonboard.com>\n\t<20260119113104.3560802-6-barnabas.pocze@ideasonboard.com>\n\t<176882727192.3486172.15264525466548732776@ping.linuxembedded.co.uk>\n\t<20260119175218.GH26642@pendragon.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":"<20260119175218.GH26642@pendragon.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>"}}]