[libcamera-devel] [PATCH 1/2] libcamera: pipeline: ipu3: Fix warning when compiled with optimization

Jean-Michel Hautbois jeanmichel.hautbois at ideasonboard.com
Mon May 31 20:26:47 CEST 2021


Hi Laurent,

On 31/05/2021 04:07, Laurent Pinchart wrote:
> When compiling with optimization, gcc 9 and newer throw an unitialized
> variable warning:
> 
> ../../src/libcamera/pipeline/ipu3/imgu.cpp: In function ‘void libcamera::{anonymous}::calculateBDSHeight(libcamera::ImgUDevice::Pipe*, const libcamera::Size&, const libcamera::Size&, unsigned int, float)’:
> ../../src/libcamera/pipeline/ipu3/imgu.cpp:172:17: error: ‘bdsHeight’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   172 |    unsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);
> 
> Neither clang not gcc versions older than 9 complain. This seems to be
> a false positive, work around it by initializing the bdsHeight variable
> when declaring it.
> 
> Note that there are obvious errors in the code, with the second while ()
> loop in the first part of calculateBDSHeight() modifying the bdsHeight
> variable set by the first loop even if the second loop doesn't find a
> suitable height, but that's out of scope for this fix.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
> ---
>  src/libcamera/pipeline/ipu3/imgu.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp
> index 3e517ac67962..f3eaab648399 100644
> --- a/src/libcamera/pipeline/ipu3/imgu.cpp
> +++ b/src/libcamera/pipeline/ipu3/imgu.cpp
> @@ -126,7 +126,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc
>  	unsigned int minIFHeight = iif.height - IF_CROP_MAX_H;
>  	unsigned int minBDSHeight = gdc.height + FILTER_H * 2;
>  	unsigned int ifHeight;
> -	float bdsHeight;
> +	float bdsHeight = 0.0f;
>  
>  	if (!isSameRatio(pipe->input, gdc)) {
>  		unsigned int foundIfHeight = 0;
> 


More information about the libcamera-devel mailing list