[RFC PATCH v1 1/7] libcamera: base: log: Move all fields of `LogMessage`

Barnabás Pőcze pobrn at protonmail.com
Tue Jan 21 19:50:52 CET 2025


Move all fields of `LogMessage` in the move constructor.

Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>
---
 src/libcamera/base/log.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp
index 3a656b8f0..61a43d525 100644
--- a/src/libcamera/base/log.cpp
+++ b/src/libcamera/base/log.cpp
@@ -17,6 +17,7 @@
 #include <syslog.h>
 #include <time.h>
 #include <unordered_set>
+#include <utility>
 
 #include <libcamera/logging.h>
 
@@ -894,9 +895,10 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,
  */
 LogMessage::LogMessage(LogMessage &&other)
 	: msgStream_(std::move(other.msgStream_)), category_(other.category_),
-	  severity_(other.severity_)
+	  severity_(std::exchange(other.severity_, LogInvalid)),
+	  timestamp_(other.timestamp_), fileInfo_(std::move(other.fileInfo_)),
+	  prefix_(std::move(other.prefix_))
 {
-	other.severity_ = LogInvalid;
 }
 
 void LogMessage::init(const char *fileName, unsigned int line)
-- 
2.48.1




More information about the libcamera-devel mailing list