From: Sergei Trofimovich <slyich@gmail.com>
To: cgen@sourceware.org
Cc: Sergei Trofimovich <siarheit@google.com>
Subject: [PATCH] cr16: fix build on gcc-12 (NULL comparison)
Date: Sun, 14 Nov 2021 17:42:41 +0000 [thread overview]
Message-ID: <20211114174241.2955314-1-slyich@gmail.com> (raw)
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
next reply other threads:[~2021-11-14 17:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-14 17:42 Sergei Trofimovich [this message]
2021-11-14 18:13 ` Mike Frysinger
2021-11-14 18:34 ` Sergei Trofimovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211114174241.2955314-1-slyich@gmail.com \
--to=slyich@gmail.com \
--cc=cgen@sourceware.org \
--cc=siarheit@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).