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>
This commit is contained in:
Laurent Pinchart 2020-01-19 00:38:04 +02:00
parent 7216c6a9bb
commit 0228e9c927
4 changed files with 4 additions and 4 deletions

View file

@ -752,7 +752,7 @@ bool ControlList::contains(unsigned int id) const
*/ */
const ControlValue &ControlList::get(unsigned int id) const const ControlValue &ControlList::get(unsigned int id) const
{ {
static ControlValue zero; static const ControlValue zero;
const ControlValue *val = find(id); const ControlValue *val = find(id);
if (!val) if (!val)

View file

@ -86,7 +86,7 @@ std::vector<unsigned int> ImageFormats::formats() const
*/ */
const std::vector<SizeRange> &ImageFormats::sizes(unsigned int format) 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); auto const &it = data_.find(format);
if (it == data_.end()) if (it == data_.end())

View file

@ -203,7 +203,7 @@ int FrameBufferAllocator::free(Stream *stream)
const std::vector<std::unique_ptr<FrameBuffer>> & const std::vector<std::unique_ptr<FrameBuffer>> &
FrameBufferAllocator::buffers(Stream *stream) const 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); auto iter = buffers_.find(stream);
if (iter == buffers_.end()) if (iter == buffers_.end())

View file

@ -749,7 +749,7 @@ void LogCategory::setSeverity(LogSeverity severity)
*/ */
const LogCategory &LogCategory::defaultCategory() const LogCategory &LogCategory::defaultCategory()
{ {
static LogCategory category("default"); static const LogCategory category("default");
return category; return category;
} }