Skip to contentSkip to conversation

user-exec: alpha-host: Add type cast to avoid compiling warning

PATCH In review gchen gchen 1 participant 2 messages Aug 12, 2015 – Aug 17, 2015 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 user-exec: alpha-host: Add type cast to avoid compiling warning

In reply to a message not in the archive

The related building warnings in alpha virtual machine:

CC i386-linux-user/user-exec.o
user-exec.c: In function 'cpu_x86_signal_handler':
user-exec.c:363:20: error: initialization makes pointer from integer without a cast [-Werror=int-conversion]

       uint32_t *pc = uc->uc_mcontext.sc_pc;
                      ^
  user-exec.c:383:30: error: passing argument 1 of 'handle_cpu_signal' makes integer from pointer without a cast [-Werror=int-conversion]
       return handle_cpu_signal(pc, (unsigned long)info->si_addr,
                                ^
  user-exec.c:86:19: note: expected 'uintptr_t {aka long unsigned int}' but argument is of type 'uint32_t * {aka unsigned int *}'
   static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
                     ^
---
 user-exec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
user-exec.c +2 -2
index ed9a07f..baaeb09 100644
@@ -360,7 +360,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    uint32_t *pc = uc->uc_mcontext.sc_pc;
+    uint32_t *pc = (uint32_t *)uc->uc_mcontext.sc_pc;
     uint32_t insn = *pc;
     int is_write = 0;
 
@@ -380,7 +380,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
         is_write = 1;
     }
 
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr,
+    return handle_cpu_signal((unsigned long)pc, (unsigned long)info->si_addr,
                              is_write, &uc->uc_sigmask, puc);
 }
 #elif defined(__sparc__)

--
1.9.1

#3 lore raw
In reply to a message not in the archive

Oh, it has been fixed, but did not merge into master branch.

commit b9b331a737f2cd34614355cc8facbbc49fc9816d

Author: Richard Henderson <[email protected]>
Date:   Fri Jan 29 15:28:51 2010 -0800

tcg-alpha: Fix type mismatch errors in cpu_signal_handler.

user-exec.c +2 -2
index bc58056..27c0f3d 100644
@@ -358,8 +358,8 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    uint32_t *pc = uc->uc_mcontext.sc_pc;
-    uint32_t insn = *pc;
+    unsigned long pc = uc->uc_mcontext.sc_pc;
+    uint32_t insn = *(uint32_t *)pc;
     int is_write = 0;
 
     /* XXX: need kernel patch to get write flag faster */
Quoted 42 lines · gchen gchen

The related building warnings in alpha virtual machine:

CC i386-linux-user/user-exec.o
user-exec.c: In function 'cpu_x86_signal_handler':
user-exec.c:363:20: error: initialization makes pointer from integer without a cast [-Werror=int-conversion]

       uint32_t *pc = uc->uc_mcontext.sc_pc;
                      ^
  user-exec.c:383:30: error: passing argument 1 of 'handle_cpu_signal' makes integer from pointer without a cast [-Werror=int-conversion]
       return handle_cpu_signal(pc, (unsigned long)info->si_addr,
                                ^
  user-exec.c:86:19: note: expected 'uintptr_t {aka long unsigned int}' but argument is of type 'uint32_t * {aka unsigned int *}'
   static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
                     ^
---
 user-exec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
user-exec.c +2 -3
index ed9a07f..baaeb09 100644
@@ -360,7 +360,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 {
     siginfo_t *info = pinfo;
     struct ucontext *uc = puc;
-    uint32_t *pc = uc->uc_mcontext.sc_pc;
+    uint32_t *pc = (uint32_t *)uc->uc_mcontext.sc_pc;
     uint32_t insn = *pc;
     int is_write = 0;
 
@@ -380,7 +380,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
         is_write = 1;
     }
 
-    return handle_cpu_signal(pc, (unsigned long)info->si_addr,
+    return handle_cpu_signal((unsigned long)pc, (unsigned long)info->si_addr,
                              is_write, &uc->uc_sigmask, puc);
 }
 #elif defined(__sparc__)
--
Quoted 3 lines

1.9.1

--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed