]> Git Repo - qemu.git/commitdiff
target/xtensa: disas/xtensa: fix coverity warnings
authorMax Filippov <[email protected]>
Thu, 18 Jan 2018 18:08:49 +0000 (10:08 -0800)
committerMax Filippov <[email protected]>
Mon, 22 Jan 2018 19:54:58 +0000 (11:54 -0800)
Coverity warnings CID 13851461385148 1385149 and 1385150 point that
xtensa_opcode_num_operands and xtensa_format_num_slots may return -1
even when xtensa_opcode_decode and xtensa_format_decode succeed. In that
case unsigned counters used to iterate through operands/slots will not
do the right thing.
Make counters and loop bounds signed to fix the warnings.

Signed-off-by: Max Filippov <[email protected]>
disas/xtensa.c
target/xtensa/translate.c

index 114326a4fc2ee22eeb60f6813f3eb751b16252f4..5e3870b9ad23a2cdbd93fc3af0b50452ee424a8f 100644 (file)
@@ -37,7 +37,7 @@ int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info)
     bfd_byte *buffer = g_malloc(1);
     int status = info->read_memory_func(memaddr, buffer, 1, info);
     xtensa_format fmt;
-    unsigned slot, slots;
+    int slot, slots;
     unsigned len;
 
     if (status) {
@@ -79,7 +79,7 @@ int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info)
 
     for (slot = 0; slot < slots; ++slot) {
         xtensa_opcode opc;
-        unsigned opnd, vopnd, opnds;
+        int opnd, vopnd, opnds;
 
         if (slot) {
             info->fprintf_func(info->stream, "; ");
index 4bdfcd24d09b104da11631b1a82f2bddda45f032..3f439203acf3f762ffc40a710e7b5b66293eadf4 100644 (file)
@@ -942,7 +942,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
     unsigned char b[MAX_INSN_LENGTH] = {cpu_ldub_code(env, dc->pc)};
     unsigned len = xtensa_op0_insn_len(dc, b[0]);
     xtensa_format fmt;
-    unsigned slot, slots;
+    int slot, slots;
     unsigned i;
 
     if (len == XTENSA_UNDEFINED) {
@@ -969,7 +969,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
     slots = xtensa_format_num_slots(isa, fmt);
     for (slot = 0; slot < slots; ++slot) {
         xtensa_opcode opc;
-        unsigned opnd, vopnd, opnds;
+        int opnd, vopnd, opnds;
         uint32_t raw_arg[MAX_OPCODE_ARGS];
         uint32_t arg[MAX_OPCODE_ARGS];
         XtensaOpcodeOps *ops;
This page took 0.030725 seconds and 4 git commands to generate.