[libcamera-devel] [PATCH v4 11/15] v4l2: camera: Prevent shadowing within V4L2Camera::Buffer

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Oct 21 17:56:04 CEST 2020


Hi Kieran,

Thank you for the patch.

On Wed, Oct 21, 2020 at 04:41:44PM +0100, Kieran Bingham wrote:
> Rename the internal member variables to use the post-fixed '_' member
> variable naming style. This in turn ensures variable shadowing does not
> occur on the constructor.

s/on the constructor/in the member initializer list of the constructor/

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

> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
>  src/v4l2/v4l2_camera.h         | 6 +++---
>  src/v4l2/v4l2_camera_proxy.cpp | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h
> index a6c35a2eb578..d238046250e3 100644
> --- a/src/v4l2/v4l2_camera.h
> +++ b/src/v4l2/v4l2_camera.h
> @@ -26,12 +26,12 @@ class V4L2Camera
>  public:
>  	struct Buffer {
>  		Buffer(unsigned int index, const FrameMetadata &data)
> -			: index(index), data(data)
> +			: index_(index), data_(data)
>  		{
>  		}
>  
> -		unsigned int index;
> -		FrameMetadata data;
> +		unsigned int index_;
> +		FrameMetadata data_;
>  	};
>  
>  	V4L2Camera(std::shared_ptr<Camera> camera);
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 7803d37ecf4f..f8bfe595e90e 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -206,8 +206,8 @@ void V4L2CameraProxy::updateBuffers()
>  {
>  	std::vector<V4L2Camera::Buffer> completedBuffers = vcam_->completedBuffers();
>  	for (const V4L2Camera::Buffer &buffer : completedBuffers) {
> -		const FrameMetadata &fmd = buffer.data;
> -		struct v4l2_buffer &buf = buffers_[buffer.index];
> +		const FrameMetadata &fmd = buffer.data_;
> +		struct v4l2_buffer &buf = buffers_[buffer.index_];
>  
>  		switch (fmd.status) {
>  		case FrameMetadata::FrameSuccess:

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list