STMicroelectronics / STM32CubeF2

STM32Cube MCU Full Package for the STM32F2 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
43 stars 25 forks source link

extraneous parentheses #13

Closed RetoFx closed 3 months ago

RetoFx commented 3 months ago

Hi My ARMCLang report in file stm32f2xx_hal_flash_ex.c Line 654 and 658

if(((__IO uint8_t )(OPTCR_BYTE1_ADDRESS) == (uint8_t)OB_RDP_LEVEL_2)) { readstatus = OB_RDP_LEVEL_2; } else if(((__IO uint8_t )(OPTCR_BYTE1_ADDRESS) == (uint8_t)OB_RDP_LEVEL_0))

stm32f2xx_hal_flash_ex.c(654): warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

stm32f2xx_hal_flash_ex.c(658): warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

Please replace it with

if(((__IO uint8_t )(OPTCR_BYTE1_ADDRESS)) == ((uint8_t)OB_RDP_LEVEL_2)) { readstatus = OB_RDP_LEVEL_2; } else if(((__IO uint8_t )(OPTCR_BYTE1_ADDRESS)) == ((uint8_t)OB_RDP_LEVEL_0))

ALABSTM commented 3 months ago

See also stm32f1xx_hal_driver#13

TOUNSTM commented 3 months ago

Hello @RetoFx,

Thank you for your contribution. As indicated in the STM32CubeF2 firmware release note, only template projects have been migrated to Arm Compiler 6 with MDK-ARM 5.31 using the “AC-like Warnings” mode. The warnings you've referenced do not fall under the category of "AC5-like warnings." As a result, we are unable to proceed with your change request.

We appreciate your understanding. Please allow me to close this issue.

With regards,

RetoFx commented 3 months ago

It did not understand why you can't improve the code.

there are extraneous parentheses

(( (__IO uint8_t )(OPTCR_BYTE1_ADDRESS) == (uint8_t)OB_RDP_LEVEL_0 ))

the outer parentheses are double. so either you remove one of them or add inner parentheses as I prefere because it addes clarification.

( ((__IO uint8_t )(OPTCR_BYTE1_ADDRESS)) == ((uint8_t)OB_RDP_LEVEL_0) )