[libcamera-devel,v2,1/4] simple-cam: Make return codes consistent for main()
diff mbox series

Message ID 20201201174314.12774-2-email@uajain.com
State Accepted
Delegated to: Kieran Bingham
Headers show
Series
  • simple-cam: Provide event-loop backed by libevent
Related show

Commit Message

Umang Jain Dec. 1, 2020, 5:43 p.m. UTC
Use EXIT_FAILURE or EXIT_SUCCESS to indicate program execution
status. These are the return codes that should be used for main()
as per the C++ standard.

Signed-off-by: Umang Jain <email@uajain.com>
---
 simple-cam.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Laurent Pinchart Dec. 1, 2020, 6:16 p.m. UTC | #1
Hi Umang,

Thank you for the patch.

On Tue, Dec 01, 2020 at 11:13:11PM +0530, Umang Jain wrote:
> Use EXIT_FAILURE or EXIT_SUCCESS to indicate program execution
> status. These are the return codes that should be used for main()
> as per the C++ standard.
> 
> Signed-off-by: Umang Jain <email@uajain.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  simple-cam.cpp | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/simple-cam.cpp b/simple-cam.cpp
> index 727bb6d..e88fb85 100644
> --- a/simple-cam.cpp
> +++ b/simple-cam.cpp
> @@ -184,7 +184,7 @@ int main()
>  	int ret = camera->configure(config.get());
>  	if (ret) {
>  		std::cout << "CONFIGURATION FAILED!" << std::endl;
> -		return -1;
> +		return EXIT_FAILURE;
>  	}
>  #endif
>  
> @@ -217,7 +217,7 @@ int main()
>  		int ret = allocator->allocate(cfg.stream());
>  		if (ret < 0) {
>  			std::cerr << "Can't allocate buffers" << std::endl;
> -			return -ENOMEM;
> +			return EXIT_FAILURE;
>  		}
>  
>  		unsigned int allocated = allocator->buffers(cfg.stream()).size();
> @@ -250,7 +250,7 @@ int main()
>  		if (!request)
>  		{
>  			std::cerr << "Can't create request" << std::endl;
> -			return -ENOMEM;
> +			return EXIT_FAILURE;
>  		}
>  
>  		const std::unique_ptr<FrameBuffer> &buffer = buffers[i];
> @@ -259,7 +259,7 @@ int main()
>  		{
>  			std::cerr << "Can't set buffer for request"
>  				  << std::endl;
> -			return ret;
> +			return EXIT_FAILURE;
>  		}
>  
>  		/*
> @@ -341,5 +341,5 @@ int main()
>  	camera.reset();
>  	cm->stop();
>  
> -	return 0;
> +	return EXIT_SUCCESS;
>  }

Patch
diff mbox series

diff --git a/simple-cam.cpp b/simple-cam.cpp
index 727bb6d..e88fb85 100644
--- a/simple-cam.cpp
+++ b/simple-cam.cpp
@@ -184,7 +184,7 @@  int main()
 	int ret = camera->configure(config.get());
 	if (ret) {
 		std::cout << "CONFIGURATION FAILED!" << std::endl;
-		return -1;
+		return EXIT_FAILURE;
 	}
 #endif
 
@@ -217,7 +217,7 @@  int main()
 		int ret = allocator->allocate(cfg.stream());
 		if (ret < 0) {
 			std::cerr << "Can't allocate buffers" << std::endl;
-			return -ENOMEM;
+			return EXIT_FAILURE;
 		}
 
 		unsigned int allocated = allocator->buffers(cfg.stream()).size();
@@ -250,7 +250,7 @@  int main()
 		if (!request)
 		{
 			std::cerr << "Can't create request" << std::endl;
-			return -ENOMEM;
+			return EXIT_FAILURE;
 		}
 
 		const std::unique_ptr<FrameBuffer> &buffer = buffers[i];
@@ -259,7 +259,7 @@  int main()
 		{
 			std::cerr << "Can't set buffer for request"
 				  << std::endl;
-			return ret;
+			return EXIT_FAILURE;
 		}
 
 		/*
@@ -341,5 +341,5 @@  int main()
 	camera.reset();
 	cm->stop();
 
-	return 0;
+	return EXIT_SUCCESS;
 }