stageGain is uninitialized in RISC-V
Dan Scally
dan.scally at ideasonboard.com
Tue May 28 15:54:09 CEST 2024
Hello
On 28/05/2024 03:31, U2FsdGVkX1 wrote:
> In RISC-V, when optimization is enabled, it will fail to build with
> the following:
> ../src/ipa/libipa/exposure_mode_helper.cpp:210:52: error: ‘stageGain’
> may be used uninitialized [-Werror=maybe-uninitialized]
> 210 | shutter = clampShutter(exposure / clampGain(stageGain));
> | ~~~~~~~~~^~~~~~~~~~~
> ../src/ipa/libipa/exposure_mode_helper.cpp:169:16: note: ‘stageGain’
> was declared here
> 169 | double stageGain;
> | ^~~~~~~~~
>
> I posted an issue on GitHub and need more people to test it
> https://github.com/kbingham/libcamera/pull/95
That's interesting...I feel like the error is...erroneous...either gains_ is not empty in which case
stageGain is initialised by at least one cycle of the for loop or it is empty, in which case it's
initialised by the guarded statement you moved. What could the optimisation be doing to introduce
the possibility of the variable being used uninitialised?
As to the actual change; declaring stageGain to be 1.0 initially is conceptually fine, but as Kieran
says the comment would need to be tweaked; it can just be split in two with the first two sentences
left where they are and the last sentence moved to explain why we're setting stageGain = 1.0 to
begin with.
More information about the libcamera-devel
mailing list