[libcamera-devel] libcamera: pipeline: rkisp1: Avoid usage of dynamic_cast<>

Message ID 20200608023234.7533-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 33d71af84e64d28be278234bf5a152aee67c9013
Headers show
Series
  • [libcamera-devel] libcamera: pipeline: rkisp1: Avoid usage of dynamic_cast<>
Related show

Commit Message

Laurent Pinchart June 8, 2020, 2:32 a.m. UTC
The logic of the code guarantees that the PipelineHandler pointer passed
to the RkISP1Frames constructor is an instance of PipelineHandlerRkISP1.
We can thus use static_cast<> instead of dynamic_cast<>.

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

Comments

Niklas Söderlund June 10, 2020, 12:20 a.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2020-06-08 05:32:34 +0300, Laurent Pinchart wrote:
> The logic of the code guarantees that the PipelineHandler pointer passed
> to the RkISP1Frames constructor is an instance of PipelineHandlerRkISP1.
> We can thus use static_cast<> instead of dynamic_cast<>.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index d807fc2cf535..094362bb0e4f 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -221,7 +221,7 @@ private:
>  };
>  
>  RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)
> -	: pipe_(dynamic_cast<PipelineHandlerRkISP1 *>(pipe))
> +	: pipe_(static_cast<PipelineHandlerRkISP1 *>(pipe))
>  {
>  }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index d807fc2cf535..094362bb0e4f 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -221,7 +221,7 @@  private:
 };
 
 RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)
-	: pipe_(dynamic_cast<PipelineHandlerRkISP1 *>(pipe))
+	: pipe_(static_cast<PipelineHandlerRkISP1 *>(pipe))
 {
 }