From patchwork Mon Feb 17 18:54:40 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: 22801 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 C4F08C3200 for ; Mon, 17 Feb 2025 18:54:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7C4C268686; Mon, 17 Feb 2025 19:54:47 +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="as1axuY4"; dkim-atps=neutral Received: from mail-10628.protonmail.ch (mail-10628.protonmail.ch [79.135.106.28]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9767A6867F for ; Mon, 17 Feb 2025 19:54:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1739818485; x=1740077685; bh=A+W+78pmn5VywPajj1M639brMT/ZaiOPzqKEXLum3aI=; h=Date:To:From:Cc: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=as1axuY4+QaqbvKgLP7fLVl+GyG7Etd4D3RhpTTVHxdUC9P1JHx+dVgExSymxFje9 EGYF0krqRt8/61Walm7WI2Px8nM04hrfbjevkbBODFKc0ZDbaUsy04z6e0aZQIOZ7H wZTwooSz85vdsYBNDj21Bn7HCpFWdFQOGmczMoJp5l5Ci2R1oWsPeKIAkUqtwjk5xa /vVIivjfp8qMRJsIzSmIF6zjix9ytBWUOm6QnqSfajI/Btw8WoipnF8ZfLaEMvvoLW vSD9OLn3H2QnuZoPONa5q64dqYX5CQSykvISTuyVUel9x3OOCPUWQqFXMatd6g/QVG OKnd97g4VsDJw== Date: Mon, 17 Feb 2025 18:54:40 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Cc: Jacopo Mondi , Laurent Pinchart Subject: [PATCH v3 1/8] libcamera: base: log: Remove move constructor Message-ID: <20250217185433.306833-2-pobrn@protonmail.com> In-Reply-To: <20250217185433.306833-1-pobrn@protonmail.com> References: <20250217185433.306833-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 2169fabd493577edbd1c08ac8d713c493f96e11d 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 cfe26f883..7a101d8ba 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(); [[nodiscard]] 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 fd1427d0b..8c72a005d 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -866,25 +866,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. */