STM32CubeF0 icon indicating copy to clipboard operation
STM32CubeF0 copied to clipboard

-Woverflow warning caused by HAL CRC function

Open mattkefford opened this issue 2 years ago • 1 comments

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:

  1. Use instead the macro from stm32f0xx.h CLEAR_REG(hcrc->Instance->IDR);
  2. 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.

mattkefford avatar Aug 15 '22 12:08 mattkefford

ST Internal Reference: 133673

HBOSTM avatar Aug 26 '22 14:08 HBOSTM