cancel
Showing results for 
Search instead for 
Did you mean: 

How can I stop getting a warning that Init.ClockDiv may be initialized in stm32l4xx_hal_sd.c?

Clark Sann
Senior

Here is the warning....

../Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_sd.c:2760:29: warning: 'Init.ClockDiv' may be used uninitialized in this function [-Wmaybe-uninitialized]

 2760 |    if ((sdmmc_clk / (Init.ClockDiv + 2U)) > SD_NORMAL_SPEED_FREQ)

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

The easiest is to disable this warning (maybe make a separate configuration with all warnings enabled, if you like so).

View solution in original post

5 REPLIES 5
Pavel A.
Evangelist III

The easiest is to disable this warning (maybe make a separate configuration with all warnings enabled, if you like so).

Clark Sann
Senior

Thank you Pavel A. I found that my configuration has -Wall set. And if I turn that off, the warning goes away. I don't like to see even warnings, but I have decided to leave -Wall set and put up with these questionable ones.

TDK
Guru

Or you could initialize Init.ClockDiv.

Allowing warnings very much leads to developers ignoring them along with futures ones that crop up.

If you feel a post has answered your question, please click "Accept as Solution".
Clark Sann
Senior

This error is in a HAL driver. I don’t see how I can initialize it. The file is overwritten by cubemx.

I’ve also found the warning goes away at higher optimization levels (above debug). Does this imply there really isn’t a problem?

But I agree, I don’t like seeing any warnings. I hope ST sees this and fixes it properly.

TDK
Guru

To be clear, the issue is in CubeMX code generation, not the HAL driver. They are separate, and one is much more robust than the other.

Not initialization ClockDiv is only a problem if it's used.

If you feel a post has answered your question, please click "Accept as Solution".