[PATCH v3 15/18] libcamera: libcamera: Formatting improvements

Milan Zamazal mzamazal at redhat.com
Mon Sep 2 17:42:08 CEST 2024


The LSP autoformatter doesn't like some of the current formatting, let's
make it happier.  Note that not all of its suggestions were accepted
because readability is preferred and adjusting .clang-format may not be
easy or possible.

Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
 src/libcamera/controls.cpp             |  2 +-
 src/libcamera/ipa_data_serializer.cpp  |  3 +--
 src/libcamera/ipa_module.cpp           |  4 ++--
 src/libcamera/orientation.cpp          | 12 ++++++++----
 src/libcamera/process.cpp              |  5 ++---
 src/libcamera/sensor/camera_sensor.cpp |  6 +++---
 src/libcamera/shared_mem_object.cpp    |  4 ++--
 src/libcamera/stream.cpp               |  1 +
 8 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 67400797..dba74404 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -8,8 +8,8 @@
 #include <libcamera/controls.h>
 
 #include <sstream>
-#include <string>
 #include <string.h>
+#include <string>
 
 #include <libcamera/base/log.h>
 #include <libcamera/base/utils.h>
diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp
index f6dd7e6f..2189a246 100644
--- a/src/libcamera/ipa_data_serializer.cpp
+++ b/src/libcamera/ipa_data_serializer.cpp
@@ -539,7 +539,6 @@ IPADataSerializer<SharedFD>::serialize(const SharedFD &data,
 	if (data.isValid())
 		fdVec.push_back(data);
 
-
 	return { dataVec, fdVec };
 }
 
@@ -606,7 +605,7 @@ IPADataSerializer<FrameBuffer::Plane>::deserialize(std::vector<uint8_t>::const_i
 	FrameBuffer::Plane ret;
 
 	ret.fd = IPADataSerializer<SharedFD>::deserialize(dataBegin, dataBegin + 4,
-								fdsBegin, fdsBegin + 1);
+							  fdsBegin, fdsBegin + 1);
 	ret.offset = readPOD<uint32_t>(dataBegin, 4, dataEnd);
 	ret.length = readPOD<uint32_t>(dataBegin, 8, dataEnd);
 
diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp
index 86d88a86..9ca74be6 100644
--- a/src/libcamera/ipa_module.cpp
+++ b/src/libcamera/ipa_module.cpp
@@ -50,8 +50,8 @@ typename std::remove_extent_t<T> *elfPointer(Span<const uint8_t> elf,
 	if (size > elf.size() || size < objSize)
 		return nullptr;
 
-	return reinterpret_cast<typename std::remove_extent_t<T> *>
-		(reinterpret_cast<const char *>(elf.data()) + offset);
+	return reinterpret_cast<typename std::remove_extent_t<T> *>(
+		reinterpret_cast<const char *>(elf.data()) + offset);
 }
 
 template<typename T>
diff --git a/src/libcamera/orientation.cpp b/src/libcamera/orientation.cpp
index bf960249..7d7d21ae 100644
--- a/src/libcamera/orientation.cpp
+++ b/src/libcamera/orientation.cpp
@@ -101,10 +101,14 @@ std::ostream &operator<<(std::ostream &out, const Orientation &orientation)
 {
 	constexpr std::array<const char *, 9> orientationNames = {
 		"", /* Orientation starts counting from 1. */
-		"Rotate0", "Rotate0Mirror",
-		"Rotate180", "Rotate180Mirror",
-		"Rotate90Mirror", "Rotate270",
-		"Rotate270Mirror", "Rotate90",
+		"Rotate0",
+		"Rotate0Mirror",
+		"Rotate180",
+		"Rotate180Mirror",
+		"Rotate90Mirror",
+		"Rotate270",
+		"Rotate270Mirror",
+		"Rotate90",
 	};
 
 	out << orientationNames[static_cast<unsigned int>(orientation)];
diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp
index c0f4d49f..bc9833f4 100644
--- a/src/libcamera/process.cpp
+++ b/src/libcamera/process.cpp
@@ -188,7 +188,6 @@ const struct sigaction &ProcessManager::oldsa() const
 	return oldsa_;
 }
 
-
 /**
  * \class Process
  * \brief Process object
@@ -270,8 +269,8 @@ int Process::start(const std::string &path,
 		unsigned int len = args.size();
 		argv[0] = path.c_str();
 		for (unsigned int i = 0; i < len; i++)
-			argv[i+1] = args[i].c_str();
-		argv[len+1] = nullptr;
+			argv[i + 1] = args[i].c_str();
+		argv[len + 1] = nullptr;
 
 		execv(path.c_str(), (char **)argv);
 
diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp
index 1382081a..4a990bb9 100644
--- a/src/libcamera/sensor/camera_sensor.cpp
+++ b/src/libcamera/sensor/camera_sensor.cpp
@@ -6,7 +6,6 @@
  */
 
 #include "libcamera/internal/camera_sensor.h"
-#include "libcamera/internal/media_device.h"
 
 #include <algorithm>
 #include <float.h>
@@ -14,15 +13,16 @@
 #include <math.h>
 #include <string.h>
 
+#include <libcamera/base/utils.h>
+
 #include <libcamera/camera.h>
 #include <libcamera/orientation.h>
 #include <libcamera/property_ids.h>
 
-#include <libcamera/base/utils.h>
-
 #include "libcamera/internal/bayer_format.h"
 #include "libcamera/internal/camera_lens.h"
 #include "libcamera/internal/camera_sensor_properties.h"
+#include "libcamera/internal/media_device.h"
 #include "libcamera/internal/sysfs.h"
 
 /**
diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp
index 65b53919..d9b61d37 100644
--- a/src/libcamera/shared_mem_object.cpp
+++ b/src/libcamera/shared_mem_object.cpp
@@ -57,8 +57,8 @@ SharedMem::SharedMem() = default;
  */
 SharedMem::SharedMem(const std::string &name, std::size_t size)
 {
-	UniqueFD memfd = MemFd::create(name.c_str(), size, MemFd::Seal::Shrink |
-				       MemFd::Seal::Grow);
+	UniqueFD memfd = MemFd::create(name.c_str(), size,
+				       MemFd::Seal::Shrink | MemFd::Seal::Grow);
 	if (!memfd.isValid())
 		return;
 
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index 33018ec1..a254d2f6 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -19,6 +19,7 @@
 #include <libcamera/base/log.h>
 #include <libcamera/base/utils.h>
 
+#include <libcamera/request.h>
 
 /**
  * \file stream.h
-- 
2.44.1



More information about the libcamera-devel mailing list