From: Cody Schafer Date: Mon, 2 Jul 2018 19:56:53 +0000 (-0400) Subject: target/image: make i/j unsigned to avoid ubsan runtime error X-Git-Tag: v0.11.0-rc1~1071 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=4a9a07b1c5189e8f9024fa843f511a0e948e61b5 target/image: make i/j unsigned to avoid ubsan runtime error src/target/image.c:1055:15: runtime error: left shift of 128 by 24 places cannot be represented in type 'int' Change-Id: I322fd391cf3f242beffc8a274824763c8c5e69a4 Signed-off-by: Cody Schafer Reviewed-on: http://openocd.zylin.com/4584 Tested-by: jenkins Reviewed-by: Tomas Vanek Reviewed-by: Christopher Head --- diff --git a/src/target/image.c b/src/target/image.c index 9f56bea045..0d98c57b2a 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -1048,8 +1048,7 @@ int image_calculate_checksum(uint8_t *buffer, uint32_t nbytes, uint32_t *checksu static bool first_init; if (!first_init) { /* Initialize the CRC table and the decoding table. */ - int i, j; - unsigned int c; + unsigned int i, j, c; for (i = 0; i < 256; i++) { /* as per gdb */ for (c = i << 24, j = 8; j > 0; --j)