{"id":9787,"url":"https://patchwork.libcamera.org/api/1.1/patches/9787/?format=json","web_url":"https://patchwork.libcamera.org/patch/9787/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200924141803.76422-1-email@uajain.com>","date":"2020-09-24T14:18:02","name":"[libcamera-devel,1/2] simple-cam: Early return if no cameras found on the system","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a49bb15cf11cb8922a3ce4b7aeae9c5f2c811116","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/people/1/?format=json","name":"Umang Jain","email":"email@uajain.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9787/mbox/","series":[{"id":1321,"url":"https://patchwork.libcamera.org/api/1.1/series/1321/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1321","date":"2020-09-24T14:18:02","name":"[libcamera-devel,1/2] simple-cam: Early return if no cameras found on the system","version":1,"mbox":"https://patchwork.libcamera.org/series/1321/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9787/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9787/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6C638C3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Sep 2020 14:18:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC1B762FE1;\n\tThu, 24 Sep 2020 16:18:11 +0200 (CEST)","from mail.uajain.com (static.126.159.217.95.clients.your-server.de\n\t[95.217.159.126])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9475960362\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Sep 2020 16:18:09 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=uajain.com header.i=@uajain.com\n\theader.b=\"H2lwtoDQ\"; dkim-atps=neutral","From":"Umang Jain <email@uajain.com>","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail;\n\tt=1600957089; bh=pk72IcqUtdO+zrVlVy6Cr0kkLrwfte2UPWojGY9lFA4=;\n\th=From:To:Cc:Subject;\n\tb=H2lwtoDQxa0W45HbidLJRlwD2cX7e0ZSHKL5/A7Nv/ve3klczjClkyeJLFumYlX/Q\n\tTAOptIm7OdZt0pL7z/0u19XnfaynW47R7H2Ij9ug3yXsRhc/mSiMYS78LwskDXskt0\n\tAr2u4E2uqleQTjiVhIRRp4w8/IWv48NZTbyKEfOG5UX4YQxVvlysbqHsvaMnTihjvG\n\tRqaA5IerKDH2INxfpEswAd+iD7iqR1E6oxBiqmFuimwiSAMvOdA2ASQ7KOitql4qZL\n\tqEwPa7Ac2n1WQIqK9My6F9f0/Bs/L/ZaCmbJw/YbaqMjUq7Wfig221clNJyo0H/KYf\n\tUJPcCJtRdVq6Q==","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 24 Sep 2020 19:48:02 +0530","Message-Id":"<20200924141803.76422-1-email@uajain.com>","Mime-Version":"1.0","Subject":"[libcamera-devel] [PATCH 1/2] simple-cam: Early return if no\n\tcameras found on the system","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Early return if no cameras are found on the system.\nFailing to do so, the codepath will segfault while trying to\nacquire a non-existent camera.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n simple-cam.cpp | 7 +++++++\n 1 file changed, 7 insertions(+)","diff":"diff --git a/simple-cam.cpp b/simple-cam.cpp\nindex 3aa975e..d51000c 100644\n--- a/simple-cam.cpp\n+++ b/simple-cam.cpp\n@@ -95,6 +95,13 @@ int main()\n \tCameraManager *cm = new CameraManager();\n \tcm->start();\n \n+\tif(!cm->cameras().size()) {\n+\t\tstd::cout << \"Please connect atleast one camera to the system.\"\n+\t\t\t  << std::endl;\n+\t\tcm->stop();\n+\t\treturn -1;\n+\t}\n+\n \t/*\n \t * Just as a test, list all id's of the Camera registered in the\n \t * system. They are indexed by name by the CameraManager.\n","prefixes":["libcamera-devel","1/2"]}