On 9/13/24 11:44, scan-ad...@coverity.com wrote:
** CID 1561133: Integer handling issues (BAD_SHIFT) /builds/qemu-project/qemu/target/loongarch/arch_dump.c: 102 in loongarch_write_elf64_fprpreg() ________________________________________________________________________________________________________ *** CID 1561133: Integer handling issues (BAD_SHIFT) /builds/qemu-project/qemu/target/loongarch/arch_dump.c: 102 in loongarch_write_elf64_fprpreg() 96 int ret, i; 97 98 loongarch_note_init(¬e, s, "CORE", 5, NT_PRFPREG, sizeof(note.fpu)); 99 note.fpu.fcsr = cpu_to_dump64(s, env->fcsr0); 100 101 for (i = 0; i < 8; i++) {
CID 1561133: Integer handling issues (BAD_SHIFT) In expression "env->cf[i] << 8 * i", left shifting by more than 31 bits has undefined behavior. The shift amount, "8 * i", is as much as 56.
102 note.fpu.fcc |= env->cf[i] << (8 * i);
Coverity is correct that 'bool' can't be shifted by 56. However there's an existing read_fcc() that gets this correct. r~