[libcamera-devel,1/3] v4l2: camera_proxy: Pass const reference to setFmtFromConfig()

Message ID 20200822134605.17666-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit a6c831a996360329bbf8e02a68a76fb556ed844b
Headers show
Series
  • v4l2: Miscellaneous cleanups
Related show

Commit Message

Laurent Pinchart Aug. 22, 2020, 1:46 p.m. UTC
The setFmtFromConfig() method doesn't modify its parameter, make it
const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/v4l2/v4l2_camera_proxy.cpp | 4 ++--
 src/v4l2/v4l2_camera_proxy.h   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Kieran Bingham Aug. 24, 2020, 9:33 a.m. UTC | #1
Hi Laurent,

On 22/08/2020 14:46, Laurent Pinchart wrote:
> The setFmtFromConfig() method doesn't modify its parameter, make it
> const.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Seems reasonable, and I'll assume it compiles ;-)

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 4 ++--
>  src/v4l2/v4l2_camera_proxy.h   | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 63affaeec1b3..079257f4bf22 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -162,10 +162,10 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory)
>  	return memory == V4L2_MEMORY_MMAP;
>  }
>  
> -void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig)
> +void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)
>  {
>  	const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat);
> -	Size size = streamConfig.size;
> +	const Size &size = streamConfig.size;
>  
>  	curV4L2Format_.fmt.pix.width        = size.width;
>  	curV4L2Format_.fmt.pix.height       = size.height;
> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
> index f06b5b87083c..79eb87bcea51 100644
> --- a/src/v4l2/v4l2_camera_proxy.h
> +++ b/src/v4l2/v4l2_camera_proxy.h
> @@ -39,7 +39,7 @@ public:
>  private:
>  	bool validateBufferType(uint32_t type);
>  	bool validateMemoryType(uint32_t memory);
> -	void setFmtFromConfig(StreamConfiguration &streamConfig);
> +	void setFmtFromConfig(const StreamConfiguration &streamConfig);
>  	void querycap(std::shared_ptr<Camera> camera);
>  	int tryFormat(struct v4l2_format *arg);
>  	enum v4l2_priority maxPriority();
>
Paul Elder Aug. 25, 2020, 3:01 a.m. UTC | #2
Hi Laurent,

On Sat, Aug 22, 2020 at 04:46:03PM +0300, Laurent Pinchart wrote:
> The setFmtFromConfig() method doesn't modify its parameter, make it
> const.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 4 ++--
>  src/v4l2/v4l2_camera_proxy.h   | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 63affaeec1b3..079257f4bf22 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -162,10 +162,10 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory)
>  	return memory == V4L2_MEMORY_MMAP;
>  }
>  
> -void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig)
> +void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)
>  {
>  	const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat);
> -	Size size = streamConfig.size;
> +	const Size &size = streamConfig.size;
>  
>  	curV4L2Format_.fmt.pix.width        = size.width;
>  	curV4L2Format_.fmt.pix.height       = size.height;
> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
> index f06b5b87083c..79eb87bcea51 100644
> --- a/src/v4l2/v4l2_camera_proxy.h
> +++ b/src/v4l2/v4l2_camera_proxy.h
> @@ -39,7 +39,7 @@ public:
>  private:
>  	bool validateBufferType(uint32_t type);
>  	bool validateMemoryType(uint32_t memory);
> -	void setFmtFromConfig(StreamConfiguration &streamConfig);
> +	void setFmtFromConfig(const StreamConfiguration &streamConfig);
>  	void querycap(std::shared_ptr<Camera> camera);
>  	int tryFormat(struct v4l2_format *arg);
>  	enum v4l2_priority maxPriority();
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 63affaeec1b3..079257f4bf22 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -162,10 +162,10 @@  bool V4L2CameraProxy::validateMemoryType(uint32_t memory)
 	return memory == V4L2_MEMORY_MMAP;
 }
 
-void V4L2CameraProxy::setFmtFromConfig(StreamConfiguration &streamConfig)
+void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)
 {
 	const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat);
-	Size size = streamConfig.size;
+	const Size &size = streamConfig.size;
 
 	curV4L2Format_.fmt.pix.width        = size.width;
 	curV4L2Format_.fmt.pix.height       = size.height;
diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
index f06b5b87083c..79eb87bcea51 100644
--- a/src/v4l2/v4l2_camera_proxy.h
+++ b/src/v4l2/v4l2_camera_proxy.h
@@ -39,7 +39,7 @@  public:
 private:
 	bool validateBufferType(uint32_t type);
 	bool validateMemoryType(uint32_t memory);
-	void setFmtFromConfig(StreamConfiguration &streamConfig);
+	void setFmtFromConfig(const StreamConfiguration &streamConfig);
 	void querycap(std::shared_ptr<Camera> camera);
 	int tryFormat(struct v4l2_format *arg);
 	enum v4l2_priority maxPriority();