From patchwork Tue Dec 1 17:43:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 10532 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 315F6BE177 for ; Tue, 1 Dec 2020 17:43:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F300263501; Tue, 1 Dec 2020 18:43:28 +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="Z0hx+GmP"; 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 B46D063507 for ; Tue, 1 Dec 2020 18:43:26 +0100 (CET) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1606844606; bh=YAuSE3bVoLNbDSNWm9ijG9eds7l5IqipAYA/Mq5598E=; h=From:To:Cc:Subject:In-Reply-To:References; b=Z0hx+GmP3FYr8pa3Z3IBJkgzZc+iuuurhBesf/hfFlpJ6Dd3kg7d+L3mUzyVpf6KT XAH32pJNk5J/FwIRjgC+0CYU+S/1xoRIModw8mEbOYcF9BqNxThL9x1fp87vZlUGj7 jueVxyUrMN1MaQ/Jfa5x6VDG6bx2rTP84COhb6V5RKIqKxnRQsE14xjesK2YL8Fuyx TXlfXiZgftBD6sQbkDpnhEj63ec9kOlMX1Y9YkXWgFJndzYZA8Bl9Olh6xOahxN9IH +nZzcjrFsEmXG2TVxvPeQ5HV9gQrdzA1RBW5/p30fZwmth8plg8z3PWKssVDawf6Ic EdjwLvSfiIhDQ== To: libcamera-devel@lists.libcamera.org Date: Tue, 1 Dec 2020 23:13:12 +0530 Message-Id: <20201201174314.12774-3-email@uajain.com> In-Reply-To: <20201201174314.12774-1-email@uajain.com> References: <20201201174314.12774-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] simple-cam: 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 Reviewed-by: Laurent Pinchart --- simple-cam.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/simple-cam.cpp b/simple-cam.cpp index e88fb85..f844ff4 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 EXIT_FAILURE; + } + /* * -------------------------------------------------------------------- * Run an EventLoop