8373447: Suspicious sign extension after integer promotion in imageDecompressor.cpp

Reviewed-by: alanb
This commit is contained in:
Chen Liang 2025-12-23 00:12:55 +00:00
parent 4b8eda3047
commit ecb42341a9

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -111,11 +111,11 @@ ImageDecompressor* ImageDecompressor::get_decompressor(const char * decompressor
u8 ImageDecompressor::getU8(u1* ptr, Endian *endian) {
u8 ret;
if (endian->is_big_endian()) {
ret = (u8)ptr[0] << 56 | (u8)ptr[1] << 48 | (u8)ptr[2]<<40 | (u8)ptr[3]<<32 |
ptr[4]<<24 | ptr[5]<<16 | ptr[6]<<8 | ptr[7];
ret = (u8)ptr[0] << 56 | (u8)ptr[1] << 48 | (u8)ptr[2] << 40 | (u8)ptr[3] << 32 |
(u8)ptr[4] << 24 | (u8)ptr[5] << 16 | (u8)ptr[6] << 8 | (u8)ptr[7];
} else {
ret = ptr[0] | ptr[1]<<8 | ptr[2]<<16 | ptr[3]<<24 | (u8)ptr[4]<<32 |
(u8)ptr[5]<<40 | (u8)ptr[6]<<48 | (u8)ptr[7]<<56;
ret = (u8)ptr[0] | (u8)ptr[1] << 8 | (u8)ptr[2] << 16 | (u8)ptr[3] << 24 |
(u8)ptr[4] << 32 | (u8)ptr[5] << 40 | (u8)ptr[6] << 48 | (u8)ptr[7] << 56;
}
return ret;
}
@ -123,9 +123,9 @@ u8 ImageDecompressor::getU8(u1* ptr, Endian *endian) {
u4 ImageDecompressor::getU4(u1* ptr, Endian *endian) {
u4 ret;
if (endian->is_big_endian()) {
ret = ptr[0] << 24 | ptr[1]<<16 | (ptr[2]<<8) | ptr[3];
ret = (u4)ptr[0] << 24 | (u4)ptr[1] << 16 | (u4)ptr[2] << 8 | (u4)ptr[3];
} else {
ret = ptr[0] | ptr[1]<<8 | (ptr[2]<<16) | ptr[3]<<24;
ret = (u4)ptr[0] | (u4)ptr[1] << 8 | (u4)ptr[2] << 16 | (u4)ptr[3] << 24;
}
return ret;
}