From patchwork Thu Jan 30 19:58:20 2025 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: 22710 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 2AC0CBD808 for ; Thu, 30 Jan 2025 19:58:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E22E76856A; Thu, 30 Jan 2025 20:58:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="yP+zyg4A"; dkim-atps=neutral Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4775A6851B for ; Thu, 30 Jan 2025 20:58:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1738267104; x=1738526304; bh=Phu7SN3abKjZBHbL7ofD5wQ30GlV8Co9upy+TiCllhg=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=yP+zyg4AUSChpmXkwazJ3NgqpTurmF1AgyH5wU70K2xQlkfcv3N5vir7XaA4Eke3i XpJggL0F5susn7feNsQHAeV0OiR13BSovvZXcn/qPkmXGr8JuKZJ5Di0MWU8rCKchp B8FkungKyG+L0w+rhRPNFIlKs82/gsE9hFM3sEsyfgdH8GO8IxKKXYH5wasouoEaDL a2ahCjnnA0UQCHh8+5gXlIWAySeEgoNOCNWht4++j9uwZnWwpdv1m5s/o7fTYfrgsQ FREfNfbQQ4brut9kapoIp7LCrGC9TN03cr/JF+8M30iDfXQCdxMeCgFbf3eKyoRtps dh7fCinT3KSug== Date: Thu, 30 Jan 2025 19:58:20 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v2 1/9] libcamera: base: log: Remove move constructor Message-ID: <20250130195811.1230581-2-pobrn@protonmail.com> In-Reply-To: <20250130195811.1230581-1-pobrn@protonmail.com> References: <20250130195811.1230581-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 6f232791b5610ed0a95bc20c539d33a8e5f12867 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" C++17 guarantees move and copy elision in certain cases, such as when returning a prvalue of the same type as the return type of the function. This is what the `_log()` functions do, thus there is no need for the move constructor, so remove it. Furthermore, do not just remove the implementation, but instead delete it as well. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/base/log.h | 4 +--- src/libcamera/base/log.cpp | 19 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h index 620930125..b3050eedb 100644 --- a/include/libcamera/base/log.h +++ b/include/libcamera/base/log.h @@ -61,8 +61,6 @@ public: LogMessage(const char *fileName, unsigned int line, const LogCategory &category, LogSeverity severity, const std::string &prefix = std::string()); - - LogMessage(LogMessage &&); ~LogMessage(); std::ostream &stream() { return msgStream_; } @@ -75,7 +73,7 @@ public: const std::string msg() const { return msgStream_.str(); } private: - LIBCAMERA_DISABLE_COPY(LogMessage) + LIBCAMERA_DISABLE_COPY_AND_MOVE(LogMessage) void init(const char *fileName, unsigned int line); diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 3a656b8f0..1917c3254 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -880,25 +880,6 @@ LogMessage::LogMessage(const char *fileName, unsigned int line, init(fileName, line); } -/** - * \brief Move-construct a log message - * \param[in] other The other message - * - * The move constructor is meant to support the _log() functions. Thanks to copy - * elision it will likely never be called, but C++11 only permits copy elision, - * it doesn't enforce it unlike C++17. To avoid potential link errors depending - * on the compiler type and version, and optimization level, the move - * constructor is defined even if it will likely never be called, and ensures - * that the destructor of the \a other message will not output anything to the - * log by setting the severity to LogInvalid. - */ -LogMessage::LogMessage(LogMessage &&other) - : msgStream_(std::move(other.msgStream_)), category_(other.category_), - severity_(other.severity_) -{ - other.severity_ = LogInvalid; -} - void LogMessage::init(const char *fileName, unsigned int line) { /* Log the timestamp, severity and file information. */