summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-19 00:38:04 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-22 17:26:17 +0200
commit0228e9c927351d483fe696e5ca6eea9c2b2cbc87 (patch)
tree2113010903387bd38c015130074858c8a1891b12
parent7216c6a9bb815ca9d0b4247f8e04d87e4ac85fa2 (diff)
libcamera: Declare static local variables as const where applicable
We use static local variables to indicate errors in methods that return a const reference. The local variables can thus be const, make them so. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r--src/libcamera/controls.cpp2
-rw-r--r--src/libcamera/formats.cpp2
-rw-r--r--src/libcamera/framebuffer_allocator.cpp2
-rw-r--r--src/libcamera/log.cpp2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 7d8a0e97..34a8c8dd 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -752,7 +752,7 @@ bool ControlList::contains(unsigned int id) const
*/
const ControlValue &ControlList::get(unsigned int id) const
{
- static ControlValue zero;
+ static const ControlValue zero;
const ControlValue *val = find(id);
if (!val)
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 6f0ffb6d..5f6552a4 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -86,7 +86,7 @@ std::vector<unsigned int> ImageFormats::formats() const
*/
const std::vector<SizeRange> &ImageFormats::sizes(unsigned int format) const
{
- static std::vector<SizeRange> empty;
+ static const std::vector<SizeRange> empty;
auto const &it = data_.find(format);
if (it == data_.end())
diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp
index 207a13bd..a7588c7f 100644
--- a/src/libcamera/framebuffer_allocator.cpp
+++ b/src/libcamera/framebuffer_allocator.cpp
@@ -203,7 +203,7 @@ int FrameBufferAllocator::free(Stream *stream)
const std::vector<std::unique_ptr<FrameBuffer>> &
FrameBufferAllocator::buffers(Stream *stream) const
{
- static std::vector<std::unique_ptr<FrameBuffer>> empty;
+ static const std::vector<std::unique_ptr<FrameBuffer>> empty;
auto iter = buffers_.find(stream);
if (iter == buffers_.end())
diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 1dac4666..1c82dc68 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -749,7 +749,7 @@ void LogCategory::setSeverity(LogSeverity severity)
*/
const LogCategory &LogCategory::defaultCategory()
{
- static LogCategory category("default");
+ static const LogCategory category("default");
return category;
}