From patchwork Thu Nov 19 12:34:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 10447 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 F031CBE08A for ; Thu, 19 Nov 2020 12:34:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0166C615AA; Thu, 19 Nov 2020 13:34:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="IAjwfltC"; dkim-atps=neutral Received: from mail.uajain.com (static.126.159.217.95.clients.your-server.de [95.217.159.126]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1AF4615A3 for ; Thu, 19 Nov 2020 13:34:36 +0100 (CET) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1605789276; bh=/smKCARF6HosYrSKrlAnihdgx7dKq8n6xByKatoxOqs=; h=From:To:Cc:Subject:In-Reply-To:References; b=IAjwfltCrVdIjk0CtKUFV/PX9jHvTKV8ZsSYmfUO1cHVAirXmYZrBzhuB+oRWIub+ qyCq18dB18qADwrwXDZ3Hznn1R+VvKmu9K3iIXvIuTkHJTUk68bOCeAH4ro04psJoh PXH2xljF56tHHgCik7GraYQNxJ7ZtoxJcuraE59OGbiaXP7CFNb9KuHT1J33d1G+q7 FEiCxeMzXqFkTB+EH2JgeqsGXiCXzzIqpmX3uau+lHrjI2FM18ZpX9mi7dbzRY+ZBX Z7JxmuXgjtZSy4/xtvb8QCvqfmWuLKVhbBwzwJa44aR4BBxtyQdMjX5asB6TcoLNVO +j/fWM5a6UYAA== To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Nov 2020 18:04:24 +0530 Message-Id: <20201119123427.53864-2-email@uajain.com> In-Reply-To: <20201119123427.53864-1-email@uajain.com> References: <20201119123427.53864-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] Early return if no cameras are found on the system. 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" Failing to do so, the codepath will segfault while trying to acquire a non-existent camera. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- simple-cam.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/simple-cam.cpp b/simple-cam.cpp index 727bb6d..af9c8b1 100644 --- a/simple-cam.cpp +++ b/simple-cam.cpp @@ -307,6 +307,13 @@ int main() for (std::unique_ptr &request : requests) camera->queueRequest(request.get()); + if(!cm->cameras().size()) { + std::cout << "No cameras were identified on the system." + << std::endl; + cm->stop(); + return -1; + } + /* * -------------------------------------------------------------------- * Run an EventLoop