[libcamera-devel] libcamera: raspberrypi: Drop std::move() where misleading
diff mbox series

Message ID 20210222104624.17643-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 1612841ff156023ff23ae5c8f4d68eeb09840a2a
Headers show
Series
  • [libcamera-devel] libcamera: raspberrypi: Drop std::move() where misleading
Related show

Commit Message

Laurent Pinchart Feb. 22, 2021, 10:46 a.m. UTC
Usage of std::move() on a const lvalue will produce a const rvalue,
which the compiler will bind to the const lvalue reference of the
constructor or assignement operator. This results in the object being
copied, not moved. Drop std::move() in that case as it's misleading.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Feb. 22, 2021, 10:57 a.m. UTC | #1
Hi Laurent,

On 22/02/2021 10:46, Laurent Pinchart wrote:
> Usage of std::move() on a const lvalue will produce a const rvalue,
> which the compiler will bind to the const lvalue reference of the
> constructor or assignement operator. This results in the object being
> copied, not moved. Drop std::move() in that case as it's misleading.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Given how I've already been confused by this - it certainly makes sense
to clear it up.

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

> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 5bab313b5cc7..46b7c6dbba0a 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -1289,7 +1289,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &
>  
>  	/* Fill the Request metadata buffer with what the IPA has provided */
>  	Request *request = requestQueue_.front();
> -	request->metadata() = std::move(controls);
> +	request->metadata() = controls;
>  
>  	/*
>  	 * Also update the ScalerCrop in the metadata with what we actually
> @@ -1338,7 +1338,7 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId)
>  
>  void RPiCameraData::setIspControls(const ControlList &controls)
>  {
> -	ControlList ctrls = std::move(controls);
> +	ControlList ctrls = controls;
>  
>  	if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) {
>  		ControlValue &value =
>
Naushir Patuck Feb. 22, 2021, 10:59 a.m. UTC | #2
Hi Laurent,

Thank you for the patch.

On Mon, 22 Feb 2021 at 10:46, Laurent Pinchart <
laurent.pinchart@ideasonboard.com> wrote:

> Usage of std::move() on a const lvalue will produce a const rvalue,
> which the compiler will bind to the const lvalue reference of the
> constructor or assignement operator. This results in the object being
> copied, not moved. Drop std::move() in that case as it's misleading.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>


> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 5bab313b5cc7..46b7c6dbba0a 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -1289,7 +1289,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t
> bufferId, const ControlList &
>
>         /* Fill the Request metadata buffer with what the IPA has provided
> */
>         Request *request = requestQueue_.front();
> -       request->metadata() = std::move(controls);
> +       request->metadata() = controls;
>
>         /*
>          * Also update the ScalerCrop in the metadata with what we actually
> @@ -1338,7 +1338,7 @@ void RPiCameraData::embeddedComplete(uint32_t
> bufferId)
>
>  void RPiCameraData::setIspControls(const ControlList &controls)
>  {
> -       ControlList ctrls = std::move(controls);
> +       ControlList ctrls = controls;
>
>         if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) {
>                 ControlValue &value =
> --
> Regards,
>
> Laurent Pinchart
>
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 5bab313b5cc7..46b7c6dbba0a 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1289,7 +1289,7 @@  void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &
 
 	/* Fill the Request metadata buffer with what the IPA has provided */
 	Request *request = requestQueue_.front();
-	request->metadata() = std::move(controls);
+	request->metadata() = controls;
 
 	/*
 	 * Also update the ScalerCrop in the metadata with what we actually
@@ -1338,7 +1338,7 @@  void RPiCameraData::embeddedComplete(uint32_t bufferId)
 
 void RPiCameraData::setIspControls(const ControlList &controls)
 {
-	ControlList ctrls = std::move(controls);
+	ControlList ctrls = controls;
 
 	if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) {
 		ControlValue &value =