Skip to content

Commit c9638d8

Browse files
int to size_t
Signed-off-by: Zhang, Winston <[email protected]>
1 parent bc330e0 commit c9638d8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

unified-runtime/source/adapters/level_zero/program.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,25 +1020,25 @@ static bool isValidSpecConstantId(const uint8_t *spirvCode, size_t spirvSize,
10201020

10211021
// Parse instructions looking for OpSpecConstant* instructions
10221022
size_t pos = headerSize;
1023-
const uint32_t *end = words + (spirvSize / sizeof(uint32_t));
1023+
const size_t totalWords = spirvSize / sizeof(uint32_t);
10241024

1025-
while (pos < (spirvSize / sizeof(uint32_t))) {
1026-
if (pos >= (end - words))
1025+
while (pos < totalWords) {
1026+
if (pos >= totalWords)
10271027
break;
10281028

10291029
uint32_t instruction = words[pos];
10301030
uint16_t opcode = instruction & 0xFFFF;
10311031
uint16_t length = instruction >> 16;
10321032

1033-
if (length == 0 || pos + length > (end - words)) {
1033+
if (length == 0 || pos + length > totalWords) {
10341034
break; // Invalid instruction
10351035
}
10361036

10371037
// OpSpecConstantTrue = 48, OpSpecConstantFalse = 49, OpSpecConstant = 50
10381038
// OpSpecConstantComposite = 51, OpSpecConstantOp = 52
10391039
if (opcode >= 48 && opcode <= 52) {
1040-
if (length >=
1041-
3) { // All OpSpecConstant* instructions have at least 3 words
1040+
if (length >= 3) {
1041+
// All OpSpecConstant* instructions have at least 3 words
10421042
// words[pos + 0] = instruction header
10431043
// words[pos + 1] = result type id
10441044
// words[pos + 2] = result id (this is the specialization constant id)

0 commit comments

Comments
 (0)