diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-04-18 21:01:00 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-04-18 21:07:25 -0400 |
commit | 3912a8db685f5e19a883d02d66900cdf10a200f0 (patch) | |
tree | 07104f4906862d7e7c2e121b728ab16658dd1d98 | |
parent | 9eab4c18bd39c0dc5b3f41892d80c130b0852e35 (diff) | |
download | gdb-3912a8db685f5e19a883d02d66900cdf10a200f0.zip gdb-3912a8db685f5e19a883d02d66900cdf10a200f0.tar.gz gdb-3912a8db685f5e19a883d02d66900cdf10a200f0.tar.bz2 |
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.
-rw-r--r-- | sim/cr16/ChangeLog | 7 | ||||
-rwxr-xr-x | sim/cr16/configure | 5 | ||||
-rw-r--r-- | sim/cr16/configure.ac | 1 | ||||
-rw-r--r-- | sim/cr16/interp.c | 5 |
4 files changed, 14 insertions, 4 deletions
diff --git a/sim/cr16/ChangeLog b/sim/cr16/ChangeLog index 274d89f..38cfe22 100644 --- a/sim/cr16/ChangeLog +++ b/sim/cr16/ChangeLog @@ -1,3 +1,10 @@ +2021-04-18 Mike Frysinger <vapier@gentoo.org> + + * interp.c (sim_open): Use PRIx64 to match mcode type. Skip the + current simop when it doesn't match a known hash table. + * configure.ac (SIM_AC_OPTION_WARNINGS): Delete call. + * configure: Regenerate. + 2021-04-12 Mike Frysinger <vapier@gentoo.org> * interp.c (sim_open): Delete 3rd arg to sim_cpu_alloc_all. diff --git a/sim/cr16/configure b/sim/cr16/configure index 16b0d72..99e21fc 100755 --- a/sim/cr16/configure +++ b/sim/cr16/configure @@ -11978,6 +11978,7 @@ fi fi + # Check whether --enable-werror was given. if test "${enable_werror+set}" = set; then : enableval=$enable_werror; case "${enableval}" in @@ -11994,6 +11995,9 @@ if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then fi WERROR_CFLAGS="" + if test "${ERROR_ON_WARNING}" = yes ; then + WERROR_CFLAGS="-Werror" + fi build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ -Wpointer-sign \ @@ -12075,7 +12079,6 @@ $as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; } fi - cgen_breaks="" if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then cgen_breaks="break cgen_rtx_error"; diff --git a/sim/cr16/configure.ac b/sim/cr16/configure.ac index 5827797..f4dc9c1 100644 --- a/sim/cr16/configure.ac +++ b/sim/cr16/configure.ac @@ -6,6 +6,5 @@ SIM_AC_COMMON SIM_AC_OPTION_ENDIAN(LITTLE) SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT) -SIM_AC_OPTION_WARNINGS(no) SIM_AC_OUTPUT diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c index f0e0f76..4615006 100644 --- a/sim/cr16/interp.c +++ b/sim/cr16/interp.c @@ -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. */ |