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 <openocd@codyps.com>
Reviewed-on: http://openocd.zylin.com/4584
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Christopher Head <chead@zaber.com>
bscan_tunnel
Cody Schafer 2018-07-02 15:56:53 -04:00 committed by Tomas Vanek
parent 73de828988
commit 4a9a07b1c5
1 changed files with 1 additions and 2 deletions

View File

@ -1048,8 +1048,7 @@ int image_calculate_checksum(uint8_t *buffer, uint32_t nbytes, uint32_t *checksu
static bool first_init; static bool first_init;
if (!first_init) { if (!first_init) {
/* Initialize the CRC table and the decoding table. */ /* Initialize the CRC table and the decoding table. */
int i, j; unsigned int i, j, c;
unsigned int c;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
/* as per gdb */ /* as per gdb */
for (c = i << 24, j = 8; j > 0; --j) for (c = i << 24, j = 8; j > 0; --j)