[binutils-gdb] sim/m32r: fix unused variable warning on non-Linux hosts

Simon Marchi via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1bf675bdada38c307058897be6f743ebd665fcdb

commit 1bf675bdada38c307058897be6f743ebd665fcdb
Author: Simon Marchi <[email protected]>
Date:   Mon Aug 17 11:16:10 2026 -0400

    sim/m32r: fix unused variable warning on non-Linux hosts
    
    When building on macOS, I get:
    
        /Users/smarchi/src/binutils-gdb/sim/m32r/traps.c:191:18: error: unused variable 'cb' [-Werror,-Wunused-variable]
          191 |   host_callback *cb = STATE_CALLBACK (sd);
              |                  ^~
    
    All the uses of `cb' in m32r_trap are inside the TRAP_LINUX_SYSCALL
    case, which is guarded by `#ifdef __linux__'.  Move the declaration
    inside that case, so that it only exists where it is used.
    
    Change-Id: I609850daf7fa60d92856988dffe7e314eb1d8a30
    Approved-By: Andrew Burgess <[email protected]>

Diff:
---
 sim/m32r/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c
index 7b98b245397..bb82ae80e2a 100644
--- a/sim/m32r/traps.c
+++ b/sim/m32r/traps.c
@@ -188,7 +188,6 @@ USI
 m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
 {
   SIM_DESC sd = CPU_STATE (current_cpu);
-  host_callback *cb = STATE_CALLBACK (sd);
 
   if (STATE_ENVIRONMENT (sd) == OPERATING_ENVIRONMENT)
     goto case_default;
@@ -217,6 +216,7 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
 #ifdef __linux__
     case TRAP_LINUX_SYSCALL:
       {
+	host_callback *cb = STATE_CALLBACK (sd);
 	CB_SYSCALL s;
 	unsigned int func, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
 	int result, errcode;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.