Skip to main content
Clark Sann
Associate III
August 21, 2021
Solved

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

  • August 21, 2021
  • 5 replies
  • 996 views

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)

This topic has been closed for replies.
Best answer by Pavel A.

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

5 replies

Pavel A.
Pavel A.Best answer
August 21, 2021

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

Clark Sann
Associate III
August 21, 2021

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
August 23, 2021

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
Associate III
August 23, 2021

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
August 23, 2021

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""."