[{"id":33554,"web_url":"https://patchwork.libcamera.org/comment/33554/","msgid":"<20250303210440.GA30583@pendragon.ideasonboard.com>","date":"2025-03-03T21:04:40","subject":"Re: [PATCH v1 1/3] libcamera: base: log: Take `LogCategory` by\n\treference","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 Mon, Mar 03, 2025 at 04:48:42PM +0100, Barnabás Pőcze wrote:\n> When no log category is specified, `nullptr` is passed,\n> and then the `_log()` function implementations replace that\n> with `LogCategory::defaultCategory()`. But since the call site\n> always knows the log category, this condition can be removed\n> and the `_LOG1()` macro can use `LogCategory::defaultCategory()`.\n> \n> So remove the condition from the `_log()` implementations and\n> use 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(-)\n> \n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index 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\n> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> index 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\nThis now holds on a single line.\n\n\treturn LogMessage(fileName, line, category, severity, logPrefix());\n\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\nSame here.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  }\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 22546C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Mar 2025 21:05:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2078D68822;\n\tMon,  3 Mar 2025 22:05:03 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F86668772\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Mar 2025 22:05:02 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 282AA346;\n\tMon,  3 Mar 2025 22:03:30 +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=\"mJ7bNtMx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741035810;\n\tbh=JfHnwY6DViJ7a4J6IWM8BtJyh5IudqYjMuJyzLSvs0E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mJ7bNtMxeIOWY0Lt4tcNojv1V265XWlFb8JRyEBBSp7wUOYSnQBuNY04Y3Yp7smmZ\n\thpcSLDEVY6v6cU69ukQr4Vr+HIVkNYV7yCeUWwVGc1wTPurkvGuO8yolA4kx4XcMy/\n\tLJr9yHRpz2NpSizqvtaVir6uKtYJ+nGZDB/EL4po=","Date":"Mon, 3 Mar 2025 23:04:40 +0200","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/3] libcamera: base: log: Take `LogCategory` by\n\treference","Message-ID":"<20250303210440.GA30583@pendragon.ideasonboard.com>","References":"<20250303154844.745574-1-barnabas.pocze@ideasonboard.com>\n\t<20250303154844.745574-2-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":"<20250303154844.745574-2-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":34985,"web_url":"https://patchwork.libcamera.org/comment/34985/","msgid":"<175312313185.50296.15471033944405494944@ping.linuxembedded.co.uk>","date":"2025-07-21T18:38:51","subject":"Re: [PATCH v1 1/3] libcamera: base: log: Take `LogCategory` by\n\treference","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2025-03-03 21:04:40)\n> Hi Barnabás,\n> \n> Thank you for the patch.\n> \n> On Mon, Mar 03, 2025 at 04:48:42PM +0100, Barnabás Pőcze wrote:\n> > When no log category is specified, `nullptr` is passed,\n> > and then the `_log()` function implementations replace that\n> > with `LogCategory::defaultCategory()`. But since the call site\n> > always knows the log category, this condition can be removed\n> > and the `_LOG1()` macro can use `LogCategory::defaultCategory()`.\n> > \n> > So remove the condition from the `_log()` implementations and\n> > use 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(-)\n> > \n> > diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> > index 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> >       virtual std::string logPrefix() const = 0;\n> >  \n> > -     LogMessage _log(const LogCategory *category, LogSeverity severity,\n> > +     LogMessage _log(const LogCategory &category, LogSeverity severity,\n> >                       const char *fileName = __builtin_FILE(),\n> >                       unsigned int line = __builtin_LINE()) const;\n> >  };\n> >  \n> > -LogMessage _log(const LogCategory *category, LogSeverity severity,\n> > +LogMessage _log(const LogCategory &category, LogSeverity severity,\n> >               const char *fileName = __builtin_FILE(),\n> >               unsigned 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> > -     _log(nullptr, Log##severity).stream()\n> > +     _log(LogCategory::defaultCategory(), Log##severity).stream()\n> >  #define _LOG2(category, severity) \\\n> > -     _log(&_LOG_CATEGORY(category)(), Log##severity).stream()\n> > +     _log(_LOG_CATEGORY(category)(), Log##severity).stream()\n> >  \n> >  /*\n> >   * Expand the LOG() macro to _LOG1() or _LOG2() based on the number of\n> > diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> > index 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> >                         const char *fileName, unsigned int line) const\n> >  {\n> >       return LogMessage(fileName, line,\n> > -                       category ? *category : LogCategory::defaultCategory(),\n> > +                       category,\n> >                         severity, logPrefix());\n> \n> This now holds on a single line.\n> \n>         return LogMessage(fileName, line, category, severity, logPrefix());\n> \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> >               const char *fileName, unsigned int line)\n> >  {\n> >       return LogMessage(fileName, line,\n> > -                       category ? *category : LogCategory::defaultCategory(),\n> > +                       category,\n> >                         severity);\n> \n> Same here.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n\nThis seems mergable ... It's not public ABI is it ?\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> >  }\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 0CC7FC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Jul 2025 18:38:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07BBD69000;\n\tMon, 21 Jul 2025 20:38:56 +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 88F5A68FB1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jul 2025 20:38:54 +0200 (CEST)","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 61BB17917;\n\tMon, 21 Jul 2025 20:38:17 +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=\"AVXyqcuM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753123097;\n\tbh=rBy6m7uX5IZ1KD333hlOPKKC1kBD8Rb77bUlM0jD56g=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=AVXyqcuM+ZlzeP7q4zvLvbgs5AbVeF5CN79mQgeNsOV+GODs4vL0dyztJgjwguKId\n\tV0SzQHGsn9Zw8a1PyM4Od0W3x3Hxdq+Imya4CxrDcyR1G63Xj8JtsdAJg46q4FQLRJ\n\toOXGngdhAGSdNhwbTGhZuY/KXXazlQ8uyQMdcyXs=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250303210440.GA30583@pendragon.ideasonboard.com>","References":"<20250303154844.745574-1-barnabas.pocze@ideasonboard.com>\n\t<20250303154844.745574-2-barnabas.pocze@ideasonboard.com>\n\t<20250303210440.GA30583@pendragon.ideasonboard.com>","Subject":"Re: [PATCH v1 1/3] libcamera: base: log: Take `LogCategory` by\n\treference","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":"Mon, 21 Jul 2025 19:38:51 +0100","Message-ID":"<175312313185.50296.15471033944405494944@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>"}}]