Message ID | 20221017032205.2210188-3-damien.lemoal@opensource.wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix compilation warnings | expand |
Hi Damien, On Mon, Oct 17, 2022 at 5:22 AM Damien Le Moal <damien.lemoal@opensource.wdc.com> wrote: > When compiling with clang and W=1, the following warning is generated: > > drivers/ata/sata_rcar.c:878:15: error: cast to smaller integer type > 'enum sata_rcar_type' from 'const void *' > [-Werror,-Wvoid-pointer-to-enum-cast] > priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Fix this by using a cast to unsigned long to match the "void *" type > size returned by of_device_get_match_data(). > > Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Modulo bike-shedding about "uintptr_t" vs. "unsigned long". I'd prefer the former (the road to Zettalinux?), but Linus prefers the latter. > --- a/drivers/ata/sata_rcar.c > +++ b/drivers/ata/sata_rcar.c > @@ -875,7 +875,7 @@ static int sata_rcar_probe(struct platform_device *pdev) > if (!priv) > return -ENOMEM; > > - priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); > + priv->type = (unsigned long)of_device_get_match_data(dev); > > pm_runtime_enable(dev); > ret = pm_runtime_get_sync(dev); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
On 10/17/22 6:22 AM, Damien Le Moal wrote: > When compiling with clang and W=1, the following warning is generated: > > drivers/ata/sata_rcar.c:878:15: error: cast to smaller integer type > 'enum sata_rcar_type' from 'const void *' > [-Werror,-Wvoid-pointer-to-enum-cast] > priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Fix this by using a cast to unsigned long to match the "void *" type > size returned by of_device_get_match_data(). > > Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> [...] MBR, Sergey
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 590ebea99601..0195eb29f6c2 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -875,7 +875,7 @@ static int sata_rcar_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); + priv->type = (unsigned long)of_device_get_match_data(dev); pm_runtime_enable(dev); ret = pm_runtime_get_sync(dev);
When compiling with clang and W=1, the following warning is generated: drivers/ata/sata_rcar.c:878:15: error: cast to smaller integer type 'enum sata_rcar_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] priv->type = (enum sata_rcar_type)of_device_get_match_data(dev); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix this by using a cast to unsigned long to match the "void *" type size returned by of_device_get_match_data(). Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> --- drivers/ata/sata_rcar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)