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

Hirokazu Honda hiroh at chromium.org
Mon May 31 05:15:45 CEST 2021


Hi Laurent, thank you for the patch.

On Mon, May 31, 2021 at 11:08 AM Laurent Pinchart <
laurent.pinchart at ideasonboard.com> 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>
>

Reviewed-by: Hirokazu Honda <hiroh at chromium.org>

> ---
>  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;
> --
> Regards,
>
> Laurent Pinchart
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210531/dc7a8973/attachment-0001.htm>


More information about the libcamera-devel mailing list