From e97436b1b789dcdb6ffb502263f4c86f8bc22996 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 14 Nov 2021 17:39:35 +0000 Subject: [PATCH] sim: cr16: fix build on gcc-12 (NULL comparison) On gcc-12 build fails as: sim/cr16/interp.c: In function 'lookup_hash': sim/cr16/interp.c:89:25: error: the comparison will always evaluate as 'true' for the address of 'mnimonic' will never be NULL [-Werror=address] 89 | if ((h->ops->mnimonic != NULL) && | ^~ 'mnimonic' is a sharr array within ops. It can never be NULL. While at it renamed 'mnimonic' to 'mnemonic'. --- sim/cr16/cr16_sim.h | 2 +- sim/cr16/interp.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sim/cr16/cr16_sim.h b/sim/cr16/cr16_sim.h index a865d093648..35a9614977c 100644 --- a/sim/cr16/cr16_sim.h +++ b/sim/cr16/cr16_sim.h @@ -59,7 +59,7 @@ typedef uint32 creg_t; struct simops { - char mnimonic[12]; + char mnemonic[12]; uint32 size; uint32 mask; uint32 opcode; diff --git a/sim/cr16/interp.c b/sim/cr16/interp.c index 7bbcf3cde7c..18e1db9f739 100644 --- a/sim/cr16/interp.c +++ b/sim/cr16/interp.c @@ -86,8 +86,7 @@ lookup_hash (SIM_DESC sd, SIM_CPU *cpu, uint64 ins, int size) mask = (((1 << (32 - h->mask)) -1) << h->mask); /* Adjuest mask for branch with 2 word instructions. */ - if ((h->ops->mnimonic != NULL) && - ((streq(h->ops->mnimonic,"b") && h->size == 2))) + if (streq(h->ops->mnemonic,"b") && h->size == 2) mask = 0xff0f0000; @@ -99,7 +98,7 @@ lookup_hash (SIM_DESC sd, SIM_CPU *cpu, uint64 ins, int size) mask = (((1 << (32 - h->mask)) -1) << h->mask); /* Adjuest mask for branch with 2 word instructions. */ - if ((streq(h->ops->mnimonic,"b")) && h->size == 2) + if ((streq(h->ops->mnemonic,"b")) && h->size == 2) mask = 0xff0f0000; } -- 2.30.2