From patchwork Mon Jan 20 00:24:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2694 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A5A7607D9 for ; Mon, 20 Jan 2020 01:24:45 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E6369563 for ; Mon, 20 Jan 2020 01:24:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1579479885; bh=xEe7fvbCYCHn301mk4SENmNkHS6ZAU4WulFUlUu0RBw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EcZCGBnABkuWH42FaE2B1XRuf3LpLDkPNEEFwWMtiCibGZKPR2l8tTVk7ospM67EH srKhmK0APS7VTjykXSt+AViu1/nFu6UBnizCEg2hxCOAr2YoE+MRxRrxBifpPqSHI3 cr3o2Rw5QmtUywki1/NCqNKUxP7ovB+uCh+udBvM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jan 2020 02:24:25 +0200 Message-Id: <20200120002437.6633-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120002437.6633-1-laurent.pinchart@ideasonboard.com> References: <20200120002437.6633-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/19] libcamera: Declare static local variables as const where applicable X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2020 00:24:47 -0000 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 Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- 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 ImageFormats::formats() const */ const std::vector &ImageFormats::sizes(unsigned int format) const { - static std::vector empty; + static const std::vector 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> & FrameBufferAllocator::buffers(Stream *stream) const { - static std::vector> empty; + static const std::vector> 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; }