Message ID | 20210531020745.13815-2-laurent.pinchart@ideasonboard.com |
---|---|
State | Rejected |
Headers | show |
Series |
|
Related | show |
Hi Laurent, thank you for the patch. On Mon, May 31, 2021 at 11:08 AM Laurent Pinchart < laurent.pinchart@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@ideasonboard.com> > Reviewed-by: Hirokazu Honda <hiroh@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 > >
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@ideasonboard.com> Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@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; >
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;
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@ideasonboard.com> --- src/libcamera/pipeline/ipu3/imgu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)