Skip to content

Commit b790a33

Browse files
committed
Fix undefined behavior in RV_MARCHID definition
The RV_MARCHID macro is defined using a left shift operation without explicitly specifying the type of the constant. This can lead to undefined behavior, specifically a shift too many bits issue. Modify the RV_MARCHID definition to use the ULL suffix for the constant, ensuring it is treated as an unsigned long long. This eliminates the undefined behavior.
1 parent ed4fe8f commit b790a33

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static inline sbi_ret_t handle_sbi_ecall_RST(vm_t *vm, int32_t fid)
185185
}
186186

187187
#define RV_MVENDORID 0x12345678
188-
#define RV_MARCHID ((1 << 31) | 1)
188+
#define RV_MARCHID ((1ULL << 31) | 1)
189189
#define RV_MIMPID 1
190190

191191
static inline sbi_ret_t handle_sbi_ecall_BASE(vm_t *vm, int32_t fid)

0 commit comments

Comments
 (0)