public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] cr16: fix build on gcc-12 (NULL comparison)
@ 2021-11-14 17:42 Sergei Trofimovich
  2021-11-14 18:13 ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Trofimovich @ 2021-11-14 17:42 UTC (permalink / raw)
  To: cgen; +Cc: 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] 3+ messages in thread

* Re: [PATCH] cr16: fix build on gcc-12 (NULL comparison)
  2021-11-14 17:42 [PATCH] cr16: fix build on gcc-12 (NULL comparison) Sergei Trofimovich
@ 2021-11-14 18:13 ` Mike Frysinger
  2021-11-14 18:34   ` Sergei Trofimovich
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2021-11-14 18:13 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: cgen, Sergei Trofimovich

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

On 14 Nov 2021 17:42, Sergei Trofimovich via Cgen wrote:
> 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(-)

this code doesn't exist in cgen.  did you mean to send the patch here ?
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cr16: fix build on gcc-12 (NULL comparison)
  2021-11-14 18:13 ` Mike Frysinger
@ 2021-11-14 18:34   ` Sergei Trofimovich
  0 siblings, 0 replies; 3+ messages in thread
From: Sergei Trofimovich @ 2021-11-14 18:34 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: cgen, Sergei Trofimovich

On Sun, 14 Nov 2021 13:13:54 -0500
Mike Frysinger <vapier@gentoo.org> wrote:

> On 14 Nov 2021 17:42, Sergei Trofimovich via Cgen wrote:
> > 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(-)  
> 
> this code doesn't exist in cgen.  did you mean to send the patch here ?
> -mike

My fault of not being able to read binutils-gdb/MAINTAINERS file.
I somehow read 'cgen/; cgen parts of opcodes/, sim/' as "all of sim/"
goes here.

Will resend to gdb-patches@sourceware.org.

Thank you!


-- 

  Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-14 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-14 17:42 [PATCH] cr16: fix build on gcc-12 (NULL comparison) Sergei Trofimovich
2021-11-14 18:13 ` Mike Frysinger
2021-11-14 18:34   ` Sergei Trofimovich

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).