STM32CubeF0
STM32CubeF0 copied to clipboard
-Woverflow warning caused by HAL CRC function
Hello, this warning started showing recently when I build my project:
../Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f0xx.h:198:41: warning: overflow in conversion from 'int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '(int)hcrc->Instance->IDR & -256' to '0' [-Woverflow]
The offending line is here in the de-init function:
https://github.com/STMicroelectronics/STM32CubeF0/blob/830a0e950d421c17abff57a2ea1e977870355519/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_crc.c#L205
I have two suggestions for fixes:
- Use instead the macro from stm32f0xx.h
CLEAR_REG(hcrc->Instance->IDR);
- Use instead the macro from the CRC header file
__HAL_CRC_SET_IDR(hcrc, 0);
I'll leave it to you to select the best fix as I may not be aware of any knock-on effects.
I would very much appreciate if this change could be made, since I usually aim for 0 errors and 0 warnings for any released firmware and this warning is the only one I have currently. With it being in the driver code I cannot simply make the change myself.
ST Internal Reference: 133673