[libcamera-devel,v3,2/4] simple-cam: Early return if no cameras are found on the system.
diff mbox series

Message ID 20201204065452.2764628-3-email@uajain.com
State Superseded
Headers show
Series
  • simple-cam: Provide event-loop backed by libevent
Related show

Commit Message

Umang Jain Dec. 4, 2020, 6:54 a.m. UTC
Failing to do so, the codepath will segfault while trying to acquire
a non-existent camera.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 simple-cam.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jacopo Mondi Dec. 4, 2020, 9:58 a.m. UTC | #1
Hello
   can we remove the end . in $subject when applying ?

Thanks
    j
On Fri, Dec 04, 2020 at 12:24:50PM +0530, Umang Jain wrote:
> Failing to do so, the codepath will segfault while trying to acquire
> a non-existent camera.
>
> Signed-off-by: Umang Jain <email@uajain.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  simple-cam.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/simple-cam.cpp b/simple-cam.cpp
> index e88fb85..aace5c8 100644
> --- a/simple-cam.cpp
> +++ b/simple-cam.cpp
> @@ -307,6 +307,13 @@ int main()
>  	for (std::unique_ptr<Request> &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
> --
> 2.26.2
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Umang Jain Dec. 4, 2020, 10:14 a.m. UTC | #2
Hi

On 12/4/20 3:28 PM, Jacopo Mondi wrote:
> Hello
>     can we remove the end . in $subject when applying ?
>
> Thanks
>      j
Damn it, Laurent pointed this out but i forgot again. Sorry.
Kieran please amend while applying.
> On Fri, Dec 04, 2020 at 12:24:50PM +0530, Umang Jain wrote:
>> Failing to do so, the codepath will segfault while trying to acquire
>> a non-existent camera.
>>
>> Signed-off-by: Umang Jain <email@uajain.com>
>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>>   simple-cam.cpp | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/simple-cam.cpp b/simple-cam.cpp
>> index e88fb85..aace5c8 100644
>> --- a/simple-cam.cpp
>> +++ b/simple-cam.cpp
>> @@ -307,6 +307,13 @@ int main()
>>   	for (std::unique_ptr<Request> &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
>> --
>> 2.26.2
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel@lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham Dec. 4, 2020, 10:28 a.m. UTC | #3
On 04/12/2020 10:14, Umang Jain wrote:
> Hi
> 
> On 12/4/20 3:28 PM, Jacopo Mondi wrote:
>> Hello
>>     can we remove the end . in $subject when applying ?
>>
>> Thanks
>>      j
> Damn it, Laurent pointed this out but i forgot again. Sorry.
> Kieran please amend while applying.

Removed.


>> On Fri, Dec 04, 2020 at 12:24:50PM +0530, Umang Jain wrote:
>>> Failing to do so, the codepath will segfault while trying to acquire
>>> a non-existent camera.
>>>
>>> Signed-off-by: Umang Jain <email@uajain.com>
>>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>>   simple-cam.cpp | 7 +++++++
>>>   1 file changed, 7 insertions(+)
>>>
>>> diff --git a/simple-cam.cpp b/simple-cam.cpp
>>> index e88fb85..aace5c8 100644
>>> --- a/simple-cam.cpp
>>> +++ b/simple-cam.cpp
>>> @@ -307,6 +307,13 @@ int main()
>>>       for (std::unique_ptr<Request> &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
>>> -- 
>>> 2.26.2
>>>
>>> _______________________________________________
>>> libcamera-devel mailing list
>>> libcamera-devel@lists.libcamera.org
>>> https://lists.libcamera.org/listinfo/libcamera-devel
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/simple-cam.cpp b/simple-cam.cpp
index e88fb85..aace5c8 100644
--- a/simple-cam.cpp
+++ b/simple-cam.cpp
@@ -307,6 +307,13 @@  int main()
 	for (std::unique_ptr<Request> &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