[libcamera-devel] [PATCH 13/20] libcamera: ipu3: cio2: Mark sensor() as const

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Jul 14 23:33:42 CEST 2020


Hi Jacopo,

Thank you for the patch.

On Tue, Jul 14, 2020 at 12:42:05PM +0200, Jacopo Mondi wrote:
> Mark the CIO2Device::sensor() method as const, and allow to call it
> on const instances of the class.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/cio2.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
> index f905d97fa79d..0f75b0bc4572 100644
> --- a/src/libcamera/pipeline/ipu3/cio2.h
> +++ b/src/libcamera/pipeline/ipu3/cio2.h
> @@ -49,7 +49,7 @@ public:
>  	int start();
>  	int stop();
>  
> -	CameraSensor *sensor() { return sensor_; }
> +	CameraSensor *sensor() const { return sensor_; }

This would calling non-const methods of the CameraSensor class from a
caller that only has access to a const CIO2Device. Wouldn't it be better
to have two methods, a const and a non-const one ?

	CameraSensor *sensor() { return sensor_; }
	const CameraSensor *sensor() const { return sensor_; }

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

>  
>  	int queueBuffer(Request *request, FrameBuffer *rawBuffer);
>  	void tryReturnBuffer(FrameBuffer *buffer);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list