[libcamera-devel,1/8] libcamera: camera: fix bug in error check for streamConfiguration()

Message ID 20190226021857.28255-2-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: improve validation of camera operations
Related show

Commit Message

Niklas Söderlund Feb. 26, 2019, 2:18 a.m. UTC
The return statement is missing altogether and an error is silently
ignored. Fix this and also update the empty map to use the correct type
for the map key.

Fixes: 65ea2422d24a3073 ("libcamera: camera: extend camera object to support configuration of streams")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/camera.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jacopo Mondi Feb. 27, 2019, 12:52 p.m. UTC | #1
Hi Niklas,

On Tue, Feb 26, 2019 at 03:18:50AM +0100, Niklas Söderlund wrote:
> The return statement is missing altogether and an error is silently
> ignored. Fix this and also update the empty map to use the correct type
> for the map key.

Sorry, forgot to reply. Please add

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j
>
> Fixes: 65ea2422d24a3073 ("libcamera: camera: extend camera object to support configuration of streams")
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/camera.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 1acb399c80a6fd3e..6409d10ff88b2189 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -213,7 +213,7 @@ std::map<Stream *, StreamConfiguration>
>  Camera::streamConfiguration(std::vector<Stream *> &streams)
>  {
>  	if (disconnected_ || !streams.size())
> -		std::map<unsigned int, StreamConfiguration> {};
> +		return std::map<Stream *, StreamConfiguration>{};
>
>  	return pipe_->streamConfiguration(this, streams);
>  }
> --
> 2.20.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Feb. 27, 2019, 12:53 p.m. UTC | #2
Hi Niklas,

Thank you for the patch.

On Tue, Feb 26, 2019 at 03:18:50AM +0100, Niklas Söderlund wrote:
> The return statement is missing altogether and an error is silently
> ignored. Fix this and also update the empty map to use the correct type
> for the map key.
> 
> Fixes: 65ea2422d24a3073 ("libcamera: camera: extend camera object to support configuration of streams")
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Oops.

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

> ---
>  src/libcamera/camera.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 1acb399c80a6fd3e..6409d10ff88b2189 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -213,7 +213,7 @@ std::map<Stream *, StreamConfiguration>
>  Camera::streamConfiguration(std::vector<Stream *> &streams)
>  {
>  	if (disconnected_ || !streams.size())
> -		std::map<unsigned int, StreamConfiguration> {};
> +		return std::map<Stream *, StreamConfiguration>{};
>  
>  	return pipe_->streamConfiguration(this, streams);
>  }
Niklas Söderlund Feb. 27, 2019, 4:30 p.m. UTC | #3
Hi,

I have pushed this single patch with Jacopo's and Laurent's tags, 
thanks!

On 2019-02-26 03:18:50 +0100, Niklas Söderlund wrote:
> The return statement is missing altogether and an error is silently
> ignored. Fix this and also update the empty map to use the correct type
> for the map key.
> 
> Fixes: 65ea2422d24a3073 ("libcamera: camera: extend camera object to support configuration of streams")
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/camera.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 1acb399c80a6fd3e..6409d10ff88b2189 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -213,7 +213,7 @@ std::map<Stream *, StreamConfiguration>
>  Camera::streamConfiguration(std::vector<Stream *> &streams)
>  {
>  	if (disconnected_ || !streams.size())
> -		std::map<unsigned int, StreamConfiguration> {};
> +		return std::map<Stream *, StreamConfiguration>{};
>  
>  	return pipe_->streamConfiguration(this, streams);
>  }
> -- 
> 2.20.1
>

Patch

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 1acb399c80a6fd3e..6409d10ff88b2189 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -213,7 +213,7 @@  std::map<Stream *, StreamConfiguration>
 Camera::streamConfiguration(std::vector<Stream *> &streams)
 {
 	if (disconnected_ || !streams.size())
-		std::map<unsigned int, StreamConfiguration> {};
+		return std::map<Stream *, StreamConfiguration>{};
 
 	return pipe_->streamConfiguration(this, streams);
 }