From 7717b209d8b2d87c437de9f1bc7f3b17a3cc8ca5 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Mon, 16 Sep 2019 18:18:31 +0300
Subject: [PATCH] Further cppcheck warnings removed

---
 applications/gui/src/camera.cpp             |  2 +-
 applications/gui/src/camera.hpp             |  2 ++
 applications/gui/src/media_panel.hpp        |  2 +-
 applications/gui/src/screen.cpp             |  6 +++---
 applications/gui/src/src_window.hpp         |  2 +-
 components/common/cpp/src/timer.cpp         |  9 +++++----
 components/rgbd-sources/src/calibrate.cpp   |  2 --
 components/rgbd-sources/test/frame_unit.cpp | 12 ++++++------
 8 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/applications/gui/src/camera.cpp b/applications/gui/src/camera.cpp
index dd8bc936a..fe7b115c7 100644
--- a/applications/gui/src/camera.cpp
+++ b/applications/gui/src/camera.cpp
@@ -18,7 +18,7 @@ private:
 	float n_;		// total number of samples
 
 public:
-	StatisticsImage(cv::Size size);
+	explicit StatisticsImage(cv::Size size);
 	StatisticsImage(cv::Size size, float max_f);
 
 	/* @brief reset all statistics to 0
diff --git a/applications/gui/src/camera.hpp b/applications/gui/src/camera.hpp
index 605560cc0..0d6e99b6d 100644
--- a/applications/gui/src/camera.hpp
+++ b/applications/gui/src/camera.hpp
@@ -19,6 +19,8 @@ class Camera {
 	Camera(ftl::gui::Screen *screen, ftl::rgbd::Source *src);
 	~Camera();
 
+	Camera(const Camera &)=delete;
+
 	ftl::rgbd::Source *source();
 
 	int width() { return (src_) ? src_->parameters().width : 0; }
diff --git a/applications/gui/src/media_panel.hpp b/applications/gui/src/media_panel.hpp
index d7f9aa993..9e9154d86 100644
--- a/applications/gui/src/media_panel.hpp
+++ b/applications/gui/src/media_panel.hpp
@@ -15,7 +15,7 @@ class Screen;
 
 class MediaPanel : public nanogui::Window {
     public:
-    MediaPanel(ftl::gui::Screen *);
+    explicit MediaPanel(ftl::gui::Screen *);
     ~MediaPanel();
 
     void cameraChanged();
diff --git a/applications/gui/src/screen.cpp b/applications/gui/src/screen.cpp
index 56624ce61..22382626d 100644
--- a/applications/gui/src/screen.cpp
+++ b/applications/gui/src/screen.cpp
@@ -51,15 +51,15 @@ namespace {
         })";
 }
 
-ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl::ctrl::Master *controller) : nanogui::Screen(Eigen::Vector2i(1024, 768), "FT-Lab Remote Presence") {
+ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl::ctrl::Master *controller) :
+		nanogui::Screen(Eigen::Vector2i(1024, 768), "FT-Lab Remote Presence"),
+		status_("FT-Lab Remote Presence System") {
 	using namespace nanogui;
 	net_ = pnet;
 	ctrl_ = controller;
 	root_ = proot;
 	camera_ = nullptr;
 
-	status_ = "FT-Lab Remote Presence System";
-
 	setSize(Vector2i(1280,720));
 
 	toolbuttheme = new Theme(*theme());
diff --git a/applications/gui/src/src_window.hpp b/applications/gui/src/src_window.hpp
index 7f28279c7..b2fe8a9e0 100644
--- a/applications/gui/src/src_window.hpp
+++ b/applications/gui/src/src_window.hpp
@@ -22,7 +22,7 @@ class Camera;
 
 class SourceWindow : public nanogui::Window {
 	public:
-	SourceWindow(ftl::gui::Screen *screen);
+	explicit SourceWindow(ftl::gui::Screen *screen);
 	~SourceWindow();
 
 	const std::vector<ftl::gui::Camera*> &getCameras();
diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp
index 252c51b83..328006ab8 100644
--- a/components/common/cpp/src/timer.cpp
+++ b/components/common/cpp/src/timer.cpp
@@ -30,9 +30,10 @@ struct TimerJob {
 	int id;
 	function<bool(int64_t)> job;
 	volatile bool active;
-	bool paused;
-	int multiplier;
-	int countdown;
+	// TODO: (Nick) Implement richer forms of timer
+	//bool paused;
+	//int multiplier;
+	//int countdown;
 	std::string name;
 };
 
@@ -109,7 +110,7 @@ const TimerHandle ftl::timer::add(timerlevel_t l, const std::function<bool(int64
 
 	UNIQUE_LOCK(mtx, lk);
 	int newid = last_id++;
-	jobs[l].push_back({newid, f, false, false, 0, 0, "NoName"});
+	jobs[l].push_back({newid, f, false, "NoName"});
 	return TimerHandle(newid);
 }
 
diff --git a/components/rgbd-sources/src/calibrate.cpp b/components/rgbd-sources/src/calibrate.cpp
index df7fac455..934ca1dcd 100644
--- a/components/rgbd-sources/src/calibrate.cpp
+++ b/components/rgbd-sources/src/calibrate.cpp
@@ -150,8 +150,6 @@ bool Calibrate::_loadCalibration(cv::Size img_size, std::pair<Mat, Mat> &map1, s
 }
 
 void Calibrate::updateCalibration(const ftl::rgbd::Camera &p) {
-	std::pair<Mat, Mat> map1, map2;
-
 	Q_.at<double>(3, 2) = 1.0 / p.baseline;
 	Q_.at<double>(2, 3) = p.fx;
 	Q_.at<double>(0, 3) = p.cx;
diff --git a/components/rgbd-sources/test/frame_unit.cpp b/components/rgbd-sources/test/frame_unit.cpp
index 9f3c5b33e..1d1648b21 100644
--- a/components/rgbd-sources/test/frame_unit.cpp
+++ b/components/rgbd-sources/test/frame_unit.cpp
@@ -32,7 +32,7 @@ TEST_CASE("Frame::get()", "") {
 		bool hadexception = false;
 
 		try {
-			auto &m = f.get<cv::Mat>(Channel::Colour);
+			f.get<cv::Mat>(Channel::Colour);
 		} catch (ftl::exception &e) {
 			hadexception = true;
 		}
@@ -45,7 +45,7 @@ TEST_CASE("Frame::get()", "") {
 		bool hadexception = false;
 
 		try {
-			auto &m = f.get<cv::cuda::GpuMat>(Channel::Colour);
+			f.get<cv::cuda::GpuMat>(Channel::Colour);
 		} catch (ftl::exception &e) {
 			hadexception = true;
 		}
@@ -138,7 +138,7 @@ TEST_CASE("Frame::createTexture()", "") {
 		bool hadexception = false;
 
 		try {
-			auto &t = f.createTexture<float>(Channel::Depth);
+			f.createTexture<float>(Channel::Depth);
 		} catch (ftl::exception &e) {
 			hadexception = true;
 		}
@@ -169,7 +169,7 @@ TEST_CASE("Frame::createTexture()", "") {
 
 		try {
 			f.create<cv::Mat>(Channel::Depth, Format<uchar4>(100,100));
-			auto &t = f.createTexture<float>(Channel::Depth);
+			f.createTexture<float>(Channel::Depth);
 		} catch (ftl::exception &e) {
 			hadexception = true;
 		}
@@ -228,7 +228,7 @@ TEST_CASE("Frame::getTexture()", "") {
 		bool hadexception = false;
 
 		try {
-			auto &t = f.getTexture<float>(Channel::Depth);
+			f.getTexture<float>(Channel::Depth);
 		} catch (ftl::exception &e) {
 			hadexception = true;
 		}
@@ -242,7 +242,7 @@ TEST_CASE("Frame::getTexture()", "") {
 
 		try {
 			f.createTexture<uchar4>(Channel::Depth, Format<uchar4>(100,100));
-			auto &t = f.getTexture<float>(Channel::Depth);
+			f.getTexture<float>(Channel::Depth);
 		} catch (ftl::exception &e) {
 			hadexception = true;
 		}
-- 
GitLab