diff mbox series

[4/8] xen: Remove useless casts

Message ID 20180704153919.12432-5-f4bug@amsat.org
State New
Headers show
Series Coccinelle cleanups | expand

Commit Message

Philippe Mathieu-Daudé July 4, 2018, 3:39 p.m. UTC
Patch created mechanically by rerunning:

  $  spatch --sp-file scripts/coccinelle/typecast.cocci \
            --macro-file scripts/cocci-macro-file.h \
            --dir . --in-place

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Markus Armbruster July 5, 2018, 5:39 a.m. UTC | #1
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Patch created mechanically by rerunning:
>
>   $  spatch --sp-file scripts/coccinelle/typecast.cocci \
>             --macro-file scripts/cocci-macro-file.h \
>             --dir . --in-place
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/xen/xen_pt_config_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index aee31c62bb..55a83333f2 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -543,7 +543,7 @@ static int xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
>  {
>      XenPTRegInfo *reg = cfg_entry->reg;
>      XenPTRegion *base = NULL;
> -    PCIDevice *d = (PCIDevice *)&s->dev;
> +    PCIDevice *d = &s->dev;
>      uint32_t writable_mask = 0;
>      uint32_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
>      pcibus_t r_size = 0;

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Anthony PERARD July 5, 2018, 10:05 a.m. UTC | #2
On Wed, Jul 04, 2018 at 12:39:15PM -0300, Philippe Mathieu-Daudé wrote:
> Patch created mechanically by rerunning:
> 
>   $  spatch --sp-file scripts/coccinelle/typecast.cocci \
>             --macro-file scripts/cocci-macro-file.h \
>             --dir . --in-place
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

> ---
>  hw/xen/xen_pt_config_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index aee31c62bb..55a83333f2 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -543,7 +543,7 @@ static int xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
>  {
>      XenPTRegInfo *reg = cfg_entry->reg;
>      XenPTRegion *base = NULL;
> -    PCIDevice *d = (PCIDevice *)&s->dev;
> +    PCIDevice *d = &s->dev;
>      uint32_t writable_mask = 0;
>      uint32_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
>      pcibus_t r_size = 0;
Peter Maydell July 5, 2018, 10:16 a.m. UTC | #3
On 4 July 2018 at 16:39, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Patch created mechanically by rerunning:
>
>   $  spatch --sp-file scripts/coccinelle/typecast.cocci \
>             --macro-file scripts/cocci-macro-file.h \
>             --dir . --in-place
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/xen/xen_pt_config_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index aee31c62bb..55a83333f2 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -543,7 +543,7 @@ static int xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
>  {
>      XenPTRegInfo *reg = cfg_entry->reg;
>      XenPTRegion *base = NULL;
> -    PCIDevice *d = (PCIDevice *)&s->dev;
> +    PCIDevice *d = &s->dev;

This line of code is odd even without the cast. XenPCIPassthroughState*
is a QOM object (TYPE_XEN_PT_DEVICE) which is a subclass of TYPE_PCI_DEVICE,
so the standard way to get the PCIDevice pointer for s would be
  PCIDevice *d = PCI_DEVICE(s);

thanks
-- PMM
Philippe Mathieu-Daudé July 5, 2018, 3:36 p.m. UTC | #4
On 07/05/2018 07:16 AM, Peter Maydell wrote:
> On 4 July 2018 at 16:39, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> Patch created mechanically by rerunning:
>>
>>   $  spatch --sp-file scripts/coccinelle/typecast.cocci \
>>             --macro-file scripts/cocci-macro-file.h \
>>             --dir . --in-place
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  hw/xen/xen_pt_config_init.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
>> index aee31c62bb..55a83333f2 100644
>> --- a/hw/xen/xen_pt_config_init.c
>> +++ b/hw/xen/xen_pt_config_init.c
>> @@ -543,7 +543,7 @@ static int xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
>>  {
>>      XenPTRegInfo *reg = cfg_entry->reg;
>>      XenPTRegion *base = NULL;
>> -    PCIDevice *d = (PCIDevice *)&s->dev;
>> +    PCIDevice *d = &s->dev;
> 
> This line of code is odd even without the cast. XenPCIPassthroughState*
> is a QOM object (TYPE_XEN_PT_DEVICE) which is a subclass of TYPE_PCI_DEVICE,
> so the standard way to get the PCIDevice pointer for s would be
>   PCIDevice *d = PCI_DEVICE(s);

You have eagle eyes...

Thanks for your review :)

Phil.
diff mbox series

Patch

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index aee31c62bb..55a83333f2 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -543,7 +543,7 @@  static int xen_pt_exp_rom_bar_reg_write(XenPCIPassthroughState *s,
 {
     XenPTRegInfo *reg = cfg_entry->reg;
     XenPTRegion *base = NULL;
-    PCIDevice *d = (PCIDevice *)&s->dev;
+    PCIDevice *d = &s->dev;
     uint32_t writable_mask = 0;
     uint32_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
     pcibus_t r_size = 0;