{"id":2694,"url":"https://patchwork.libcamera.org/api/patches/2694/?format=json","web_url":"https://patchwork.libcamera.org/patch/2694/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200120002437.6633-8-laurent.pinchart@ideasonboard.com>","date":"2020-01-20T00:24:25","name":"[libcamera-devel,07/19] libcamera: Declare static local variables as const where applicable","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"59495317fd0b850b341a7f80d32190ad2799fca5","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2694/mbox/","series":[{"id":641,"url":"https://patchwork.libcamera.org/api/series/641/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=641","date":"2020-01-20T00:24:19","name":"Initial libcamera threading model","version":1,"mbox":"https://patchwork.libcamera.org/series/641/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2694/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2694/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A5A7607D9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 01:24:45 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E6369563\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 01:24:44 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579479885;\n\tbh=xEe7fvbCYCHn301mk4SENmNkHS6ZAU4WulFUlUu0RBw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=EcZCGBnABkuWH42FaE2B1XRuf3LpLDkPNEEFwWMtiCibGZKPR2l8tTVk7ospM67EH\n\tsrKhmK0APS7VTjykXSt+AViu1/nFu6UBnizCEg2hxCOAr2YoE+MRxRrxBifpPqSHI3\n\tcr3o2Rw5QmtUywki1/NCqNKUxP7ovB+uCh+udBvM=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 07/19] libcamera: Declare static local\n\tvariables as const where applicable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 20 Jan 2020 00:24:47 -0000"},"content":"We use static local variables to indicate errors in methods that return\na const reference. The local variables can thus be const, make them so.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/controls.cpp              | 2 +-\n src/libcamera/formats.cpp               | 2 +-\n src/libcamera/framebuffer_allocator.cpp | 2 +-\n src/libcamera/log.cpp                   | 2 +-\n 4 files changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 7d8a0e97ee3a..34a8c8dd9458 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -752,7 +752,7 @@ bool ControlList::contains(unsigned int id) const\n  */\n const ControlValue &ControlList::get(unsigned int id) const\n {\n-\tstatic ControlValue zero;\n+\tstatic const ControlValue zero;\n \n \tconst ControlValue *val = find(id);\n \tif (!val)\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex 6f0ffb6dc5a8..5f6552a4e06c 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -86,7 +86,7 @@ std::vector<unsigned int> ImageFormats::formats() const\n  */\n const std::vector<SizeRange> &ImageFormats::sizes(unsigned int format) const\n {\n-\tstatic std::vector<SizeRange> empty;\n+\tstatic const std::vector<SizeRange> empty;\n \n \tauto const &it = data_.find(format);\n \tif (it == data_.end())\ndiff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp\nindex 207a13bd841d..a7588c7fe4c2 100644\n--- a/src/libcamera/framebuffer_allocator.cpp\n+++ b/src/libcamera/framebuffer_allocator.cpp\n@@ -203,7 +203,7 @@ int FrameBufferAllocator::free(Stream *stream)\n const std::vector<std::unique_ptr<FrameBuffer>> &\n FrameBufferAllocator::buffers(Stream *stream) const\n {\n-\tstatic std::vector<std::unique_ptr<FrameBuffer>> empty;\n+\tstatic const std::vector<std::unique_ptr<FrameBuffer>> empty;\n \n \tauto iter = buffers_.find(stream);\n \tif (iter == buffers_.end())\ndiff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp\nindex ef0b81f77131..2bb09ac7a7bc 100644\n--- a/src/libcamera/log.cpp\n+++ b/src/libcamera/log.cpp\n@@ -750,7 +750,7 @@ void LogCategory::setSeverity(LogSeverity severity)\n  */\n const LogCategory &LogCategory::defaultCategory()\n {\n-\tstatic LogCategory category(\"default\");\n+\tstatic const LogCategory category(\"default\");\n \treturn category;\n }\n \n","prefixes":["libcamera-devel","07/19"]}