From 1074604c9e2b6d9afa0247f2ca62b3140131d639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Tue, 4 Aug 2020 00:49:42 +0200 Subject: cam: Use the common cleanup function on failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The different error paths in init() are out of sync. Instead of fixing them switch to using the cleanup() function which does the right thing for all cases. Signed-off-by: Niklas Söderlund Reviewed-by: Paul Elder --- src/cam/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/cam') diff --git a/src/cam/main.cpp b/src/cam/main.cpp index ec59e9ea..6761d638 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -107,22 +107,23 @@ int CamApp::init(int argc, char **argv) std::cout << "Camera " << std::string(options_[OptCamera]) << " not found" << std::endl; - cm_->stop(); + cleanup(); return -ENODEV; } if (camera_->acquire()) { std::cout << "Failed to acquire camera" << std::endl; - camera_.reset(); - cm_->stop(); + cleanup(); return -EINVAL; } std::cout << "Using camera " << camera_->name() << std::endl; ret = prepareConfig(); - if (ret) + if (ret) { + cleanup(); return ret; + } } if (options_.isSet(OptMonitor)) { -- cgit v1.2.1