[libcamera-devel] [PATCH 07/19] libcamera: Declare static local variables as const where applicable
Jacopo Mondi
jacopo at jmondi.org
Mon Jan 20 14:29:17 CET 2020
Hi Laurent
On Mon, Jan 20, 2020 at 02:24:25AM +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>
I had a quick look and found no other occurencies that would benefit
for a similar change
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Thanks
j
> ---
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20200120/64e7be77/attachment.sig>
More information about the libcamera-devel
mailing list