Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] sim/erc32: fix -Wunused-but-set-global errors
@ 2026-10-30 15:01 Simon Marchi
  2026-11-20 17:41 ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2026-10-30 15:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi, Andrew Burgess, Mike Frysinger

Building the erc32 simulator with a recent clang fails with:

    /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:159:19: error: variable 'mec_icr' set but not used [-Werror,-Wunused-but-set-global]
    /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:165:19: error: variable 'posted_irq' set but not used [-Werror,-Wunused-but-set-global]
    /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:247:19: error: variable 'uarta_data' set but not used [-Werror,-Wunused-but-set-global]

mec_icr and posted_irq are only ever set to 0 in mec_reset.  Remove
them.

uarta_data and uartb_data are only read when FAST_UART is not defined,
but the simulator is build with FAST_UART by default.  Mark them
ATTRIBUTE_UNUSED, like functions uart_rx, uarta_tx and uartb_tx, which
are in the same situation.

Cc: Andrew Burgess <aburgess@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Change-Id: I56d04a1141f05a9e1a66984a68c390a36ad9b0a1
---
 sim/erc32/erc32.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
index 4e9b645d1f3a..f3d9b49b9807 100644
--- a/sim/erc32/erc32.c
+++ b/sim/erc32/erc32.c
@@ -156,13 +156,11 @@ static uint32_t   mec_ffar;
 static uint32_t   mec_ipr;
 static uint32_t   mec_imr;
 static uint32_t   mec_isr;
-static uint32_t   mec_icr;
 static uint32_t   mec_ifr;
 static uint32_t   mec_mcr;	/* MEC control register */
 static uint32_t   mec_memcfg;	/* Memory control register */
 static uint32_t   mec_wcr;	/* MEC waitstate register */
 static uint32_t   mec_iocr;	/* MEC IO control register */
-static uint32_t   posted_irq;
 static uint32_t   mec_ersr;	/* MEC error and status register */
 static uint32_t   mec_tcr;	/* MEC test comtrol register */
 
@@ -244,7 +242,7 @@ static int      f1open = 0, f2open = 0;
 
 static char     uarta_sreg, uarta_hreg, uartb_sreg, uartb_hreg;
 static uint32_t   uart_stat_reg;
-static uint32_t   uarta_data, uartb_data;
+ATTRIBUTE_UNUSED static uint32_t uarta_data, uartb_data;
 
 #ifdef ERA
 int era = 0;
@@ -504,7 +502,6 @@ mec_reset(void)
     mec_ipr = 0;
     mec_imr = 0x7ffe;
     mec_isr = 0;
-    mec_icr = 0;
     mec_ifr = 0;
     mec_memcfg = 0x10000;
     mec_wcr = -1;
@@ -515,7 +512,6 @@ mec_reset(void)
     decode_wcr();
     decode_mcr();
 
-    posted_irq = 0;
     wnuma = wnumb = 0;
     anum = aind = bnum = bind = 0;
 

base-commit: bb0a4659ab1eb997ad095181ef309f7b7d9aa289
-- 
2.56.0


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

* Re: [PATCH] sim/erc32: fix -Wunused-but-set-global errors
  2026-10-30 15:01 [PATCH] sim/erc32: fix -Wunused-but-set-global errors Simon Marchi
@ 2026-11-20 17:41 ` Andrew Burgess
  2026-11-21  2:44   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2026-11-20 17:41 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: Simon Marchi, Mike Frysinger

Simon Marchi <simon.marchi@efficios.com> writes:

> Building the erc32 simulator with a recent clang fails with:
>
>     /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:159:19: error: variable 'mec_icr' set but not used [-Werror,-Wunused-but-set-global]
>     /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:165:19: error: variable 'posted_irq' set but not used [-Werror,-Wunused-but-set-global]
>     /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:247:19: error: variable 'uarta_data' set but not used [-Werror,-Wunused-but-set-global]
>
> mec_icr and posted_irq are only ever set to 0 in mec_reset.  Remove
> them.
>
> uarta_data and uartb_data are only read when FAST_UART is not defined,
> but the simulator is build with FAST_UART by default.  Mark them
> ATTRIBUTE_UNUSED, like functions uart_rx, uarta_tx and uartb_tx, which
> are in the same situation.

All seems reasonable to me.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> Cc: Andrew Burgess <aburgess@redhat.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
> Change-Id: I56d04a1141f05a9e1a66984a68c390a36ad9b0a1
> ---
>  sim/erc32/erc32.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
> index 4e9b645d1f3a..f3d9b49b9807 100644
> --- a/sim/erc32/erc32.c
> +++ b/sim/erc32/erc32.c
> @@ -156,13 +156,11 @@ static uint32_t   mec_ffar;
>  static uint32_t   mec_ipr;
>  static uint32_t   mec_imr;
>  static uint32_t   mec_isr;
> -static uint32_t   mec_icr;
>  static uint32_t   mec_ifr;
>  static uint32_t   mec_mcr;	/* MEC control register */
>  static uint32_t   mec_memcfg;	/* Memory control register */
>  static uint32_t   mec_wcr;	/* MEC waitstate register */
>  static uint32_t   mec_iocr;	/* MEC IO control register */
> -static uint32_t   posted_irq;
>  static uint32_t   mec_ersr;	/* MEC error and status register */
>  static uint32_t   mec_tcr;	/* MEC test comtrol register */
>  
> @@ -244,7 +242,7 @@ static int      f1open = 0, f2open = 0;
>  
>  static char     uarta_sreg, uarta_hreg, uartb_sreg, uartb_hreg;
>  static uint32_t   uart_stat_reg;
> -static uint32_t   uarta_data, uartb_data;
> +ATTRIBUTE_UNUSED static uint32_t uarta_data, uartb_data;
>  
>  #ifdef ERA
>  int era = 0;
> @@ -504,7 +502,6 @@ mec_reset(void)
>      mec_ipr = 0;
>      mec_imr = 0x7ffe;
>      mec_isr = 0;
> -    mec_icr = 0;
>      mec_ifr = 0;
>      mec_memcfg = 0x10000;
>      mec_wcr = -1;
> @@ -515,7 +512,6 @@ mec_reset(void)
>      decode_wcr();
>      decode_mcr();
>  
> -    posted_irq = 0;
>      wnuma = wnumb = 0;
>      anum = aind = bnum = bind = 0;
>  
>
> base-commit: bb0a4659ab1eb997ad095181ef309f7b7d9aa289
> -- 
> 2.56.0


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

* Re: [PATCH] sim/erc32: fix -Wunused-but-set-global errors
  2026-11-20 17:41 ` Andrew Burgess
@ 2026-11-21  2:44   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-11-21  2:44 UTC (permalink / raw)
  To: Andrew Burgess, Simon Marchi, gdb-patches; +Cc: Mike Frysinger

On 11/20/26 12:41 PM, Andrew Burgess wrote:
> Simon Marchi <simon.marchi@efficios.com> writes:
> 
>> Building the erc32 simulator with a recent clang fails with:
>>
>>     /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:159:19: error: variable 'mec_icr' set but not used [-Werror,-Wunused-but-set-global]
>>     /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:165:19: error: variable 'posted_irq' set but not used [-Werror,-Wunused-but-set-global]
>>     /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:247:19: error: variable 'uarta_data' set but not used [-Werror,-Wunused-but-set-global]
>>
>> mec_icr and posted_irq are only ever set to 0 in mec_reset.  Remove
>> them.
>>
>> uarta_data and uartb_data are only read when FAST_UART is not defined,
>> but the simulator is build with FAST_UART by default.  Mark them
>> ATTRIBUTE_UNUSED, like functions uart_rx, uarta_tx and uartb_tx, which
>> are in the same situation.
> 
> All seems reasonable to me.
> 
> Approved-By: Andrew Burgess <aburgess@redhat.com>
> 
> Thanks,
> Andrew

Thanks, pushed.

Simon

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

end of thread, other threads:[~2026-11-21  2:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 15:01 [PATCH] sim/erc32: fix -Wunused-but-set-global errors Simon Marchi
2026-11-20 17:41 ` Andrew Burgess
2026-11-21  2:44   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox