[32/40] sim/ppc: Add an explicit cast

Message ID 8d3ab3bfabd02995d344ace8016e5b09c14462eb.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 to hw_phb_decode type.
---
 sim/ppc/hw_phb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 3:10 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 to hw_phb_decode type.
> ---
>  sim/ppc/hw_phb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sim/ppc/hw_phb.c b/sim/ppc/hw_phb.c
> index a3c19264235..a99a51d9cf9 100644
> --- a/sim/ppc/hw_phb.c
> +++ b/sim/ppc/hw_phb.c
> @@ -319,7 +319,7 @@ hw_phb_attach_address(device *me,
>    /* attach it to the relevent bus */
>    DTRACE(phb, ("attach %s - %s %s:0x%lx (0x%lx bytes)\n",
>  	       device_path(client),
> -	       hw_phb_decode_name(type),
> +	       hw_phb_decode_name((hw_phb_decode)type),

this assumes the enums attach_type & hw_phb_decode are the same.  they aren't.
so this looks like a real bug, and adding a cast covers it up.  we should fix
the bug.
-mike
  

Patch

diff --git a/sim/ppc/hw_phb.c b/sim/ppc/hw_phb.c
index a3c19264235..a99a51d9cf9 100644
--- a/sim/ppc/hw_phb.c
+++ b/sim/ppc/hw_phb.c
@@ -319,7 +319,7 @@  hw_phb_attach_address(device *me,
   /* attach it to the relevent bus */
   DTRACE(phb, ("attach %s - %s %s:0x%lx (0x%lx bytes)\n",
 	       device_path(client),
-	       hw_phb_decode_name(type),
+	       hw_phb_decode_name((hw_phb_decode)type),
 	       pci_space->name,
 	       (unsigned long)addr,
 	       (unsigned long)nr_bytes));