From 7e0eda3530dd710957cebbe8cd76b0532d252f57 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 25 Jul 2020 21:59:36 +0300
Subject: [PATCH] Remove some compiler warnings

---
 CMakeLists.txt                                |  2 +-
 applications/ftl2mkv/src/main.cpp             |  7 ++-
 applications/gui2/src/views/addsource.cpp     |  1 -
 components/common/cpp/src/timer.cpp           |  2 +-
 .../src/sources/stereovideo/opencv.cpp        |  2 +-
 .../src/sources/stereovideo/pylon.cpp         | 45 -------------------
 components/streams/src/feed.cpp               |  2 +-
 7 files changed, 9 insertions(+), 52 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d2b26c52e..58dce1b8a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -397,7 +397,7 @@ if (WIN32) # TODO(nick) Should do based upon compiler (VS)
 else()
 	add_definitions(-DUNIX)
 	# -fdiagnostics-color
-	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fPIC -msse3 -Wall -Werror=unused-result -Werror=return-type")
+	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fPIC -msse3 -Wall -Werror=unused-result -Werror=return-type -Wno-deprecated-copy")
 	set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
 	set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -mfpmath=sse")
 	set(OS_LIBS "dl")
diff --git a/applications/ftl2mkv/src/main.cpp b/applications/ftl2mkv/src/main.cpp
index b78986464..267039dd2 100644
--- a/applications/ftl2mkv/src/main.cpp
+++ b/applications/ftl2mkv/src/main.cpp
@@ -111,7 +111,7 @@ int main(int argc, char **argv) {
 	AVFormatContext *oc;
 	AVStream *video_st[10][2] = {nullptr};
 
-	av_register_all();
+	//av_register_all();
 
 	fmt = av_guess_format(NULL, outputfile.c_str(), NULL);
 
@@ -127,7 +127,10 @@ int main(int argc, char **argv) {
         return -1;
     }
     oc->oformat = fmt;
-	snprintf(oc->filename, sizeof(oc->filename), "%s", outputfile.c_str());
+	//snprintf(oc->filename, sizeof(oc->filename), "%s", outputfile.c_str());
+
+	oc->url = (char*)av_malloc(outputfile.size()+1);
+	snprintf(oc->url, outputfile.size()+1, "%s", outputfile.c_str());
 
 	/* open the output file, if needed */
     if (!(fmt->flags & AVFMT_NOFILE)) {
diff --git a/applications/gui2/src/views/addsource.cpp b/applications/gui2/src/views/addsource.cpp
index f92203601..362eb2a4f 100644
--- a/applications/gui2/src/views/addsource.cpp
+++ b/applications/gui2/src/views/addsource.cpp
@@ -102,7 +102,6 @@ void AddSourceWindow::rebuild() {
 	auto srcs = ctrl_->getRecent();
 
 	for (auto &s : srcs) {
-		LOG(INFO) << "ADD RECENT: " << s.uri;
 		_addButton(s.uri, recentscroll);
 	}
 
diff --git a/components/common/cpp/src/timer.cpp b/components/common/cpp/src/timer.cpp
index 2ef443241..8b83ef6ec 100644
--- a/components/common/cpp/src/timer.cpp
+++ b/components/common/cpp/src/timer.cpp
@@ -219,7 +219,7 @@ static void trigger_jobs() {
 		auto *pj = &j;
 
 		// If last job in list then do in this thread
-		if (active_jobs == jobs[kTimerMain].size()+1) {
+		if (active_jobs == static_cast<int>(jobs[kTimerMain].size())+1) {
 			lk.unlock();
 			bool doremove = !pj->job.trigger(ts);
 			pj->active = false;
diff --git a/components/rgbd-sources/src/sources/stereovideo/opencv.cpp b/components/rgbd-sources/src/sources/stereovideo/opencv.cpp
index ba48e7b26..b3c2ba810 100644
--- a/components/rgbd-sources/src/sources/stereovideo/opencv.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/opencv.cpp
@@ -440,7 +440,7 @@ bool OpenCVDevice::isStereo() const {
 }
 
 void OpenCVDevice::populateMeta(std::map<std::string,std::string> &meta) const {
-	if (dev_ix_left_ >= 0 && dev_ix_left_ < opencv_devices.size()) {
+	if (dev_ix_left_ >= 0 && dev_ix_left_ < static_cast<int>(opencv_devices.size())) {
 		meta["device"] = opencv_devices[dev_ix_left_].name;
 	}
 }
diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
index 160c389e1..98e86714b 100644
--- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp
@@ -277,28 +277,9 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda
 		if (rcam_) {
 			future_b = std::move(ftl::pool.push([this,&rfull,&r,&l,c,&r_out,&h_r,&stream](int id) {
 				Pylon::CGrabResultPtr result_right;
-				int rcount = 0;
-				//if (rcam_->NumReadyBuffers.GetValue() > 1) LOG(WARNING) << "Frames lost in retrieve (right) = " << rcam_->NumReadyBuffers.GetValue();
-
-				/*do {
-					if (rcam_->RetrieveResult(0, result_right, Pylon::TimeoutHandling_Return)) {
-						if (!result_right->GrabSucceeded()) {
-							LOG(ERROR) << "Right retrieve failed " << result_right->GetErrorDescription();
-						}
-					} else {
-						LOG(ERROR) << "Right frame missing";
-						return false;
-					}
-				} while (!result_right->GrabSucceeded());*/
 
 				if (!_retrieveFrames(result_right, rcam_)) return false;
 
-				/*if (rcount == 0 || !result_right->GrabSucceeded()) {
-					LOG(ERROR) << "Right retrieve failed " << ((rcount > 0) ? result_right->GetErrorDescription() : 0);
-					if (rcount == 0) ++right_fail_;
-					return false;
-				}*/
-
 				cv::Mat wrap_right(
 				result_right->GetHeight(),
 				result_right->GetWidth(),
@@ -329,21 +310,6 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda
 		}
 
 		Pylon::CGrabResultPtr result_left;
-		//if (lcam_->NumReadyBuffers.GetValue() > 1) LOG(WARNING) << "Frames lost in retrieve (left) = " << lcam_->NumReadyBuffers.GetValue();
-		int lcount = 0;
-		/*do {
-			if (lcam_->RetrieveResult(0, result_left, Pylon::TimeoutHandling_Return)) {
-				if (!result_left->GrabSucceeded()) {
-					LOG(ERROR) << "Left retrieve failed " << result_left->GetErrorDescription();
-				}
-			} else {
-				LOG(ERROR) << "Left frame missing";
-				if (rcam_) {
-					future_b.wait();
-				}
-				return false;
-			}
-		} while (!result_left->GrabSucceeded());*/
 
 		if (!_retrieveFrames(result_left, lcam_)) {
 			if (rcam_) {
@@ -352,17 +318,6 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda
 			return false;
 		}
 
-
-		/*{
-			if (lcam_->RetrieveResult(100, result_left, Pylon::TimeoutHandling_Return)) ++lcount;
-		}
-
-		if (lcount == 0 || !result_left->GrabSucceeded()) {
-			LOG(ERROR) << "Left retrieve failed " <<  ((lcount > 0) ? result_left->GetErrorDescription() : 0);
-			if (lcount == 0) ++left_fail_;
-			return false;
-		}*/
-
 		cv::Mat wrap_left(
 			result_left->GetHeight(),
 			result_left->GetWidth(),
diff --git a/components/streams/src/feed.cpp b/components/streams/src/feed.cpp
index ff7c11fce..0a6fb2da8 100644
--- a/components/streams/src/feed.cpp
+++ b/components/streams/src/feed.cpp
@@ -168,7 +168,7 @@ Feed::Feed(nlohmann::json &config, ftl::net::Universe*net) :
 	handle_receiver_ = receiver_->onFrameSet(
 		[this](const ftl::data::FrameSetPtr& fs) {
 			if (value("drop_partial_framesets", false)) {
-				if (fs->count < fs->frames.size()) {
+				if (fs->count < static_cast<int>(fs->frames.size())) {
 					LOG(WARNING) << "Dropping partial frameset: " << fs->timestamp();
 					return true;
 				}
-- 
GitLab