[25/40] sim/mn10300: Add an explicit cast

Message ID dfe8bf9505900c9a3ff13ca771a6fc2b812d60aa.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  Clang generates a warning if there is an enum value with a mismatching type
without an explicit cast ("-Wenum-conversion").
On the default configuration, it causes a build failure
(unless "--disable-werror" is specified).

This commit adds an explicit cast.
---
 sim/mn10300/op_utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 3:03 p.m. UTC | #1
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> Clang generates a warning if there is an enum value with a mismatching type
> without an explicit cast ("-Wenum-conversion").
> On the default configuration, it causes a build failure
> (unless "--disable-werror" is specified).
> 
> This commit adds an explicit cast.
> ---
>  sim/mn10300/op_utils.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> --- a/sim/mn10300/op_utils.c
> +++ b/sim/mn10300/op_utils.c
> @@ -152,8 +152,9 @@ do_syscall (SIM_DESC sd)
>    if (cb_target_to_host_syscall (STATE_CALLBACK (sd), func) == CB_SYS_exit)
>      {
>        /* EXIT - caller can look in parm1 to work out the reason */
> -      sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
> -		       (parm1 == 0xdead ? SIM_SIGABRT : sim_exited), parm1);
> +      sim_engine_halt (
> +	  simulator, STATE_CPU (simulator, 0), NULL, PC,
> +	  (parm1 == 0xdead ? (enum sim_stop) SIM_SIGABRT : sim_exited), parm1);

i'm fairly certain the existing code is wrong, and adding the cast masks that
error.  so we don't want to do this.

signals should be passed as the sigrc argument.
-mike
  

Patch

diff --git a/sim/mn10300/op_utils.c b/sim/mn10300/op_utils.c
index 2fccf2da207..34b1b8e3951 100644
--- a/sim/mn10300/op_utils.c
+++ b/sim/mn10300/op_utils.c
@@ -152,8 +152,9 @@  do_syscall (SIM_DESC sd)
   if (cb_target_to_host_syscall (STATE_CALLBACK (sd), func) == CB_SYS_exit)
     {
       /* EXIT - caller can look in parm1 to work out the reason */
-      sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
-		       (parm1 == 0xdead ? SIM_SIGABRT : sim_exited), parm1);
+      sim_engine_halt (
+	  simulator, STATE_CPU (simulator, 0), NULL, PC,
+	  (parm1 == 0xdead ? (enum sim_stop) SIM_SIGABRT : sim_exited), parm1);
     }
   else
     {