* [PATCH] cr16: fix build on gcc-12 (NULL comparison)
@ 2021-11-14 18:35 Sergei Trofimovich
2021-11-15 2:45 ` Mike Frysinger
0 siblings, 1 reply; 2+ messages in thread
From: Sergei Trofimovich @ 2021-11-14 18:35 UTC (permalink / raw)
To: gdb-patches; +Cc: M R Swami Reddy, Sergei Trofimovich
From: Sergei Trofimovich <siarheit@google.com>
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 e2aef013d16..ecc61362200 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.33.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] cr16: fix build on gcc-12 (NULL comparison)
2021-11-14 18:35 [PATCH] cr16: fix build on gcc-12 (NULL comparison) Sergei Trofimovich
@ 2021-11-15 2:45 ` Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2021-11-15 2:45 UTC (permalink / raw)
To: Sergei Trofimovich; +Cc: gdb-patches, Sergei Trofimovich, M R Swami Reddy
[-- Attachment #1: Type: text/plain, Size: 19 bytes --]
lgtm, thanks
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-15 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-14 18:35 [PATCH] cr16: fix build on gcc-12 (NULL comparison) Sergei Trofimovich
2021-11-15 2:45 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).