From patchwork Mon Aug 3 23:03:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9164 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 77510BD86F for ; Mon, 3 Aug 2020 23:03:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 013A56092F; Tue, 4 Aug 2020 01:03:46 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 516E560393 for ; Tue, 4 Aug 2020 01:03:45 +0200 (CEST) X-Halon-ID: 5bd21b8a-d5dd-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 5bd21b8a-d5dd-11ea-86ee-0050569116f7; Tue, 04 Aug 2020 01:02:20 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Aug 2020 01:03:28 +0200 Message-Id: <20200803230328.1125040-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] cam: Use the common cleanup function on failure 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The different error paths in init() are out of sync. Instead of fixing them switch to using the cleanup() function which does to right thing in 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(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index ec59e9eaf1176a94..6761d63801bd19af 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)) {