[libcamera-devel] [PATCH 07/19] libcamera: Declare static local variables as const where applicable
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Jan 22 16:19:01 CET 2020
Hi Laurent,
Thanks for your patch.
On 2020-01-20 02:24:25 +0200, Laurent Pinchart wrote:
> 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 at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> src/libcamera/controls.cpp | 2 +-
> src/libcamera/formats.cpp | 2 +-
> src/libcamera/framebuffer_allocator.cpp | 2 +-
> src/libcamera/log.cpp | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 7d8a0e97ee3a..34a8c8dd9458 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 6f0ffb6dc5a8..5f6552a4e06c 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 207a13bd841d..a7588c7fe4c2 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 ef0b81f77131..2bb09ac7a7bc 100644
> --- a/src/libcamera/log.cpp
> +++ b/src/libcamera/log.cpp
> @@ -750,7 +750,7 @@ void LogCategory::setSeverity(LogSeverity severity)
> */
> const LogCategory &LogCategory::defaultCategory()
> {
> - static LogCategory category("default");
> + static const LogCategory category("default");
> return category;
> }
>
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list