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:
Mike Frysinger
2021-04-18 21:01:00 -04:00
parent 9eab4c18bd
commit 3912a8db68
4 changed files with 14 additions and 4 deletions

View File

@@ -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. */