forked from Imagelibrary/binutils-gdb
sim: cr16: fix build warnings
The printf fix is obvious enough, but the hash one is a real bug:
cr16/interp.c: In function 'sim_open':
cr16/interp.c:560:17: error: 'h' may be used uninitialized in this function [-Werror=maybe-uninitialized]
560 | h = h->next;
| ~~^~~~~~~~~
It happens to not cause a problem currently because the first entry in
the generated table that this loop operates matches a codepath where h
is initialized. Then when later entries don't match, the previous value
is pointing at the end of a valid hash table already, and the rest of
the code does nothing.
With this tidied up, we can delete the SIM_AC_OPTION_WARNINGS(no) call
to get the default common behavior where -Werror is enabled.
This commit is contained in:
@@ -330,7 +330,7 @@ do_run (SIM_DESC sd, SIM_CPU *cpu, uint64 mcode)
|
||||
|
||||
#ifdef DEBUG
|
||||
if ((cr16_debug & DEBUG_INSTRUCTION) != 0)
|
||||
sim_io_printf (sd, "do_long 0x%x\n", mcode);
|
||||
sim_io_printf (sd, "do_long 0x%" PRIx64 "\n", mcode);
|
||||
#endif
|
||||
|
||||
h = lookup_hash (sd, cpu, mcode, 1);
|
||||
@@ -543,8 +543,9 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb,
|
||||
else
|
||||
h = &hash_table[hash(s->opcode, 0)];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* go to the last entry in the chain. */
|
||||
|
||||
Reference in New Issue
Block a user