1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

helpers.c: use unsigned int for bit shifts (ASAN)

This change addresses the following ASAN error detected in the chromium
tree:

 * ASAN error detected:
 * ../flashrom-9999/helpers.c:28:13: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
 *     #0 0x5589a94bb284 in address_to_bits /build/amd64-generic/tmp/portage/sys-apps/flashrom-9999/work/flashrom-9999-build/../flashrom-9999/helpers.c:28:13
 *
 * SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../flashrom-9999/helpers.c:28:13 in

BUG=b:224828279
TEST=./test_build.sh; FEATURES=test emerge-amd64-generic flashrom
BRANCH=none

Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: Ib595f13c29dd5c0775e074801756e4f920b4daaf
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62862
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Daniel Campello 2022-03-16 07:05:48 -06:00 committed by Anastasia Klimchuk
parent f31650b23b
commit e1dd0068c2

View File

@ -25,7 +25,7 @@
uint32_t address_to_bits(uint32_t addr)
{
unsigned int lzb = 0;
while (((1 << (31 - lzb)) & ~addr) != 0)
while (((1u << (31 - lzb)) & ~addr) != 0)
lzb++;
return 32 - lzb;
}