[libcamera-devel,4/4] cam: fix return type of configureStreams()

Message ID 20190220235939.25147-5-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: enforce stream configuration
Related show

Commit Message

Niklas Söderlund Feb. 20, 2019, 11:59 p.m. UTC
The only caller of configureStreams() stores its return value as an int
and not bool. This is confusing and also prevents the (possibly)
different error codes returned by Camera::configureStreams() to be
propagated inside the cam tool. Fix this by changing the return type to
int and propagate the return value from the camera.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/cam/main.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Laurent Pinchart Feb. 22, 2019, 10:51 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Thu, Feb 21, 2019 at 12:59:39AM +0100, Niklas Söderlund wrote:
> The only caller of configureStreams() stores its return value as an int
> and not bool. This is confusing and also prevents the (possibly)
> different error codes returned by Camera::configureStreams() to be
> propagated inside the cam tool. Fix this by changing the return type to
> int and propagate the return value from the camera.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

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

> ---
>  src/cam/main.cpp | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index 9b67ab75a6a1663e..7c47ce652aa025d1 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -78,7 +78,7 @@ static int parseOptions(int argc, char *argv[])
>  	return 0;
>  }
>  
> -static bool configureStreams(Camera *camera, std::vector<Stream *> &streams)
> +static int configureStreams(Camera *camera, std::vector<Stream *> &streams)
>  {
>  	KeyValueParser::Options format = options[OptFormat];
>  	Stream *id = streams.front();
> @@ -98,10 +98,7 @@ static bool configureStreams(Camera *camera, std::vector<Stream *> &streams)
>  			config[id].pixelFormat = format["pixelformat"];
>  	}
>  
> -	if (camera->configureStreams(config))
> -		return false;
> -
> -	return true;
> +	return camera->configureStreams(config);
>  }
>  
>  static void requestComplete(Request *request, const std::map<Stream *, Buffer *> &buffers)

Patch

diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 9b67ab75a6a1663e..7c47ce652aa025d1 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -78,7 +78,7 @@  static int parseOptions(int argc, char *argv[])
 	return 0;
 }
 
-static bool configureStreams(Camera *camera, std::vector<Stream *> &streams)
+static int configureStreams(Camera *camera, std::vector<Stream *> &streams)
 {
 	KeyValueParser::Options format = options[OptFormat];
 	Stream *id = streams.front();
@@ -98,10 +98,7 @@  static bool configureStreams(Camera *camera, std::vector<Stream *> &streams)
 			config[id].pixelFormat = format["pixelformat"];
 	}
 
-	if (camera->configureStreams(config))
-		return false;
-
-	return true;
+	return camera->configureStreams(config);
 }
 
 static void requestComplete(Request *request, const std::map<Stream *, Buffer *> &buffers)