flash/stm32l4x: prevent undefined behavior warnings caused by signed integer operations
authorSebastiaan de Schaetzen <sebastiaan.de.schaetzen@gmail.com>
Sun, 15 Aug 2021 22:26:23 +0000 (23:26 +0100)
committerOleksij Rempel <linux@rempel-privat.de>
Thu, 26 Aug 2021 06:38:45 +0000 (06:38 +0000)
commit64fbd607874bbe9726cf1d09c2cbf547bd9d804c
treef29c1a71ebae5a1be3a4320ee431eb0bb6bf69b9
parent43d31a8fd507a7d15083b487cf06d3f934e25843
flash/stm32l4x: prevent undefined behavior warnings caused by signed integer operations

When running OpenOCD with -fsanitize=undefined, a warning is emitted
for an bit-shifting operation whose result cannot be stored in a
signed integer.

This is because (1 << 31) overflows a signed integer, which is
undefined behavior. By making each of the bit masks act on an
unsigned number, the warning is avoided.

Whether this warning emitted by UBSan would ever manifest into a real
error is debatable, but fixing this does make UBSan happy.

Change-Id: I0455a26b234cb4f5e239a6ba90023d28380e9464
Signed-off-by: Sebastiaan de Schaetzen <sebastiaan.de.schaetzen@gmail.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6429
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
src/flash/nor/stm32l4x.h