[{"id":33260,"web_url":"https://patchwork.libcamera.org/comment/33260/","msgid":"<hsl7mgdaessnmjmgf2i3n4jrpqzoxfwyy4d5kioilv7pyshkoq@u4pmhotfyb7a>","date":"2025-02-03T16:23:25","subject":"Re: [RFC PATCH v2 1/9] libcamera: base: log: Remove move constructor","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Thu, Jan 30, 2025 at 07:58:20PM +0000, Barnabás Pőcze wrote:\n> C++17 guarantees move and copy elision in certain cases,\n> such as when returning a prvalue of the same type as the\n> return type of the function.\n>\n> This is what the `_log()` functions do, thus there is no need\n> for the move constructor, so remove it. Furthermore, do not\n> just remove the implementation, but instead delete it as well.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nNow that we're past c++11 this is fine\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  include/libcamera/base/log.h |  4 +---\n>  src/libcamera/base/log.cpp   | 19 -------------------\n>  2 files changed, 1 insertion(+), 22 deletions(-)\n>\n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index 620930125..b3050eedb 100644\n> --- a/include/libcamera/base/log.h\n> +++ b/include/libcamera/base/log.h\n> @@ -61,8 +61,6 @@ public:\n>  \tLogMessage(const char *fileName, unsigned int line,\n>  \t\t   const LogCategory &category, LogSeverity severity,\n>  \t\t   const std::string &prefix = std::string());\n> -\n> -\tLogMessage(LogMessage &&);\n>  \t~LogMessage();\n>\n>  \tstd::ostream &stream() { return msgStream_; }\n> @@ -75,7 +73,7 @@ public:\n>  \tconst std::string msg() const { return msgStream_.str(); }\n>\n>  private:\n> -\tLIBCAMERA_DISABLE_COPY(LogMessage)\n> +\tLIBCAMERA_DISABLE_COPY_AND_MOVE(LogMessage)\n>\n>  \tvoid init(const char *fileName, unsigned int line);\n>\n> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> index 3a656b8f0..1917c3254 100644\n> --- a/src/libcamera/base/log.cpp\n> +++ b/src/libcamera/base/log.cpp\n> @@ -880,25 +880,6 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,\n>  \tinit(fileName, line);\n>  }\n>\n> -/**\n> - * \\brief Move-construct a log message\n> - * \\param[in] other The other message\n> - *\n> - * The move constructor is meant to support the _log() functions. Thanks to copy\n> - * elision it will likely never be called, but C++11 only permits copy elision,\n> - * it doesn't enforce it unlike C++17. To avoid potential link errors depending\n> - * on the compiler type and version, and optimization level, the move\n> - * constructor is defined even if it will likely never be called, and ensures\n> - * that the destructor of the \\a other message will not output anything to the\n> - * log by setting the severity to LogInvalid.\n> - */\n> -LogMessage::LogMessage(LogMessage &&other)\n> -\t: msgStream_(std::move(other.msgStream_)), category_(other.category_),\n> -\t  severity_(other.severity_)\n> -{\n> -\tother.severity_ = LogInvalid;\n> -}\n> -\n>  void LogMessage::init(const char *fileName, unsigned int line)\n>  {\n>  \t/* Log the timestamp, severity and file information. */\n> --\n> 2.48.1\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 6D555BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 16:23:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18F5568598;\n\tMon,  3 Feb 2025 17:23:30 +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 7B4FA6858D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 17:23:28 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 104A5497;\n\tMon,  3 Feb 2025 17:22:17 +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=\"P66yc6e3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1738599737;\n\tbh=lrhBcHfQ4gzYJ0PA/QdIjkCMJ+RWAKJyDJuLTv1Ej2A=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=P66yc6e3HLaeQGqW+jqFpJhD5lerOExO9Fv+HS/1QstmPTmeDUzEE6TtjaRFNG+ZS\n\t0OmJBnL3WhkO6nRU3xAzHl1vAnmZnOeSSV6NREg1y+D4eIEZR3L2STIhoyYremSFc9\n\trfUoWIxosfE2mNZJHV4HvMdNPYWABG8/qafUZNi0=","Date":"Mon, 3 Feb 2025 17:23:25 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 1/9] libcamera: base: log: Remove move constructor","Message-ID":"<hsl7mgdaessnmjmgf2i3n4jrpqzoxfwyy4d5kioilv7pyshkoq@u4pmhotfyb7a>","References":"<20250130195811.1230581-1-pobrn@protonmail.com>\n\t<20250130195811.1230581-2-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250130195811.1230581-2-pobrn@protonmail.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":33278,"web_url":"https://patchwork.libcamera.org/comment/33278/","msgid":"<20250203192336.GC22963@pendragon.ideasonboard.com>","date":"2025-02-03T19:23:36","subject":"Re: [RFC PATCH v2 1/9] libcamera: base: log: Remove move constructor","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, Jan 30, 2025 at 07:58:20PM +0000, Barnabás Pőcze wrote:\n> C++17 guarantees move and copy elision in certain cases,\n> such as when returning a prvalue of the same type as the\n> return type of the function.\n> \n> This is what the `_log()` functions do, thus there is no need\n> for the move constructor, so remove it. Furthermore, do not\n> just remove the implementation, but instead delete it as well.\n> \n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/base/log.h |  4 +---\n>  src/libcamera/base/log.cpp   | 19 -------------------\n>  2 files changed, 1 insertion(+), 22 deletions(-)\n> \n> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\n> index 620930125..b3050eedb 100644\n> --- a/include/libcamera/base/log.h\n> +++ b/include/libcamera/base/log.h\n> @@ -61,8 +61,6 @@ public:\n>  \tLogMessage(const char *fileName, unsigned int line,\n>  \t\t   const LogCategory &category, LogSeverity severity,\n>  \t\t   const std::string &prefix = std::string());\n> -\n> -\tLogMessage(LogMessage &&);\n>  \t~LogMessage();\n>  \n>  \tstd::ostream &stream() { return msgStream_; }\n> @@ -75,7 +73,7 @@ public:\n>  \tconst std::string msg() const { return msgStream_.str(); }\n>  \n>  private:\n> -\tLIBCAMERA_DISABLE_COPY(LogMessage)\n> +\tLIBCAMERA_DISABLE_COPY_AND_MOVE(LogMessage)\n>  \n>  \tvoid init(const char *fileName, unsigned int line);\n>  \n> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> index 3a656b8f0..1917c3254 100644\n> --- a/src/libcamera/base/log.cpp\n> +++ b/src/libcamera/base/log.cpp\n> @@ -880,25 +880,6 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,\n>  \tinit(fileName, line);\n>  }\n>  \n> -/**\n> - * \\brief Move-construct a log message\n> - * \\param[in] other The other message\n> - *\n> - * The move constructor is meant to support the _log() functions. Thanks to copy\n> - * elision it will likely never be called, but C++11 only permits copy elision,\n> - * it doesn't enforce it unlike C++17. To avoid potential link errors depending\n> - * on the compiler type and version, and optimization level, the move\n> - * constructor is defined even if it will likely never be called, and ensures\n> - * that the destructor of the \\a other message will not output anything to the\n> - * log by setting the severity to LogInvalid.\n> - */\n> -LogMessage::LogMessage(LogMessage &&other)\n> -\t: msgStream_(std::move(other.msgStream_)), category_(other.category_),\n> -\t  severity_(other.severity_)\n> -{\n> -\tother.severity_ = LogInvalid;\n> -}\n> -\n>  void LogMessage::init(const char *fileName, unsigned int line)\n>  {\n>  \t/* Log the timestamp, severity and file information. */","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 9427ABD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 19:23:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9DECE685A8;\n\tMon,  3 Feb 2025 20:23:41 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F30961876\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 20:23:40 +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 B9539514;\n\tMon,  3 Feb 2025 20:22:28 +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=\"JvoKiLVJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1738610549;\n\tbh=ubC6IW+ADvljPTOeAgVAy+p9BQF93uJl/frMTi8yooI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JvoKiLVJ3NNc6o7sTLMdPQSnvYSG2SpAXLBn8SJ8UXDTbEgGM0Jua7eNgWEyxABVX\n\tbTuh6O0rbLzQUOAp8T2cuZZmGnPUkLg4pBqP58k0J/5reHDGAnk3wxhFpTsU371qKF\n\t4DO2szFJTvt6PGWBtPkURQj7CGJ+xs53GGk0I4jA=","Date":"Mon, 3 Feb 2025 21:23:36 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 1/9] libcamera: base: log: Remove move constructor","Message-ID":"<20250203192336.GC22963@pendragon.ideasonboard.com>","References":"<20250130195811.1230581-1-pobrn@protonmail.com>\n\t<20250130195811.1230581-2-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250130195811.1230581-2-pobrn@protonmail.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>"}}]