* [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning
@ 2025-04-15 8:51 Andy Shevchenko
2025-04-15 11:39 ` Corey Minyard
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-15 8:51 UTC (permalink / raw)
To: openipmi-developer, linux-kernel, llvm
Cc: Corey Minyard, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Andy Shevchenko
Debian clang version 19.1.7 is not happy when compiled with
`make W=1` (note, CONFIG_WERROR=y is the default):
ipmi_si_platform.c:268:15: error: cast to smaller integer type 'enum si_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
268 | io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
Fix this by intermediate cast to the uintptr_t, that makes compiler happy.
Fixes: 5be50eb5ae99 ("ipmi: si: Use device_get_match_data()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/char/ipmi/ipmi_si_platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
index 550cabd43ae6..47d3cbeb3fa0 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -265,7 +265,7 @@ static int of_ipmi_probe(struct platform_device *pdev)
}
memset(&io, 0, sizeof(io));
- io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
+ io.si_type = (enum si_type)(uintptr_t)device_get_match_data(&pdev->dev);
io.addr_source = SI_DEVICETREE;
io.irq_setup = ipmi_std_irq_setup;
--
2.47.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning
2025-04-15 8:51 [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning Andy Shevchenko
@ 2025-04-15 11:39 ` Corey Minyard
2025-04-15 12:06 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Corey Minyard @ 2025-04-15 11:39 UTC (permalink / raw)
To: Andy Shevchenko
Cc: openipmi-developer, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Tue, Apr 15, 2025 at 11:51:56AM +0300, Andy Shevchenko wrote:
> Debian clang version 19.1.7 is not happy when compiled with
> `make W=1` (note, CONFIG_WERROR=y is the default):
>
> ipmi_si_platform.c:268:15: error: cast to smaller integer type 'enum si_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
> 268 | io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
>
> Fix this by intermediate cast to the uintptr_t, that makes compiler happy.
Unless things have changed recently, Linus prefers "unsigned long" per
https://patchwork.kernel.org/project/linux-hardening/patch/20220616143617.449094-1-Jason@zx2c4.com/#24899749
And it would match what is in the match table.
Is that change ok?
-corey
>
> Fixes: 5be50eb5ae99 ("ipmi: si: Use device_get_match_data()")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/char/ipmi/ipmi_si_platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> index 550cabd43ae6..47d3cbeb3fa0 100644
> --- a/drivers/char/ipmi/ipmi_si_platform.c
> +++ b/drivers/char/ipmi/ipmi_si_platform.c
> @@ -265,7 +265,7 @@ static int of_ipmi_probe(struct platform_device *pdev)
> }
>
> memset(&io, 0, sizeof(io));
> - io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
> + io.si_type = (enum si_type)(uintptr_t)device_get_match_data(&pdev->dev);
> io.addr_source = SI_DEVICETREE;
> io.irq_setup = ipmi_std_irq_setup;
>
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning
2025-04-15 11:39 ` Corey Minyard
@ 2025-04-15 12:06 ` Andy Shevchenko
2025-04-15 12:11 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-15 12:06 UTC (permalink / raw)
To: Corey Minyard
Cc: openipmi-developer, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Tue, Apr 15, 2025 at 06:39:03AM -0500, Corey Minyard wrote:
> On Tue, Apr 15, 2025 at 11:51:56AM +0300, Andy Shevchenko wrote:
> > Debian clang version 19.1.7 is not happy when compiled with
> > `make W=1` (note, CONFIG_WERROR=y is the default):
> >
> > ipmi_si_platform.c:268:15: error: cast to smaller integer type 'enum si_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
> > 268 | io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
> >
> > Fix this by intermediate cast to the uintptr_t, that makes compiler happy.
>
> Unless things have changed recently, Linus prefers "unsigned long" per
> https://patchwork.kernel.org/project/linux-hardening/patch/20220616143617.449094-1-Jason@zx2c4.com/#24899749
I'm not sure I got your point. That discussion seems irrelevant to me.
They are talking about pointer-as-an-integer cases. Here we already know
that we are passing integer-as-a-pointer and this is the opposite
conversion.
> And it would match what is in the match table.
Match tables are tend to move to pointers, enum is usually goes to int.
> Is that change ok?
If you don't like my change, please do yours and consider this as
a bug report that needs to be addressed. I prefer more my solution
as we do that in many places for the exact scenario.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning
2025-04-15 12:06 ` Andy Shevchenko
@ 2025-04-15 12:11 ` Andy Shevchenko
2025-04-15 19:09 ` Corey Minyard
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-15 12:11 UTC (permalink / raw)
To: Corey Minyard
Cc: openipmi-developer, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Tue, Apr 15, 2025 at 03:06:45PM +0300, Andy Shevchenko wrote:
> On Tue, Apr 15, 2025 at 06:39:03AM -0500, Corey Minyard wrote:
> > On Tue, Apr 15, 2025 at 11:51:56AM +0300, Andy Shevchenko wrote:
> > > Debian clang version 19.1.7 is not happy when compiled with
> > > `make W=1` (note, CONFIG_WERROR=y is the default):
> > >
> > > ipmi_si_platform.c:268:15: error: cast to smaller integer type 'enum si_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
> > > 268 | io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
> > >
> > > Fix this by intermediate cast to the uintptr_t, that makes compiler happy.
> >
> > Unless things have changed recently, Linus prefers "unsigned long" per
> > https://patchwork.kernel.org/project/linux-hardening/patch/20220616143617.449094-1-Jason@zx2c4.com/#24899749
>
> I'm not sure I got your point. That discussion seems irrelevant to me.
> They are talking about pointer-as-an-integer cases. Here we already know
> that we are passing integer-as-a-pointer and this is the opposite
> conversion.
>
> > And it would match what is in the match table.
>
> Match tables are tend to move to pointers, enum is usually goes to int.
>
> > Is that change ok?
>
> If you don't like my change, please do yours and consider this as
> a bug report that needs to be addressed. I prefer more my solution
> as we do that in many places for the exact scenario.
Note, the proper solution to the cases like this is to move to info-like
structure and actually operate with the pointers instead of enums, longs, etc.
That's what's slowly moving on in IIO subsystem, for instance.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning
2025-04-15 12:11 ` Andy Shevchenko
@ 2025-04-15 19:09 ` Corey Minyard
2025-04-16 6:34 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Corey Minyard @ 2025-04-15 19:09 UTC (permalink / raw)
To: Andy Shevchenko
Cc: openipmi-developer, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Tue, Apr 15, 2025 at 03:11:56PM +0300, Andy Shevchenko wrote:
> On Tue, Apr 15, 2025 at 03:06:45PM +0300, Andy Shevchenko wrote:
> > On Tue, Apr 15, 2025 at 06:39:03AM -0500, Corey Minyard wrote:
> > > On Tue, Apr 15, 2025 at 11:51:56AM +0300, Andy Shevchenko wrote:
> > > > Debian clang version 19.1.7 is not happy when compiled with
> > > > `make W=1` (note, CONFIG_WERROR=y is the default):
> > > >
> > > > ipmi_si_platform.c:268:15: error: cast to smaller integer type 'enum si_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
> > > > 268 | io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
> > > >
> > > > Fix this by intermediate cast to the uintptr_t, that makes compiler happy.
> > >
> > > Unless things have changed recently, Linus prefers "unsigned long" per
> > > https://patchwork.kernel.org/project/linux-hardening/patch/20220616143617.449094-1-Jason@zx2c4.com/#24899749
> >
> > I'm not sure I got your point. That discussion seems irrelevant to me.
> > They are talking about pointer-as-an-integer cases. Here we already know
> > that we are passing integer-as-a-pointer and this is the opposite
> > conversion.
> >
> > > And it would match what is in the match table.
> >
> > Match tables are tend to move to pointers, enum is usually goes to int.
> >
> > > Is that change ok?
> >
> > If you don't like my change, please do yours and consider this as
> > a bug report that needs to be addressed. I prefer more my solution
> > as we do that in many places for the exact scenario.
>
> Note, the proper solution to the cases like this is to move to info-like
> structure and actually operate with the pointers instead of enums, longs, etc.
>
> That's what's slowly moving on in IIO subsystem, for instance.
Yes, you are right, I'll probably make that change. I'm not sure
about the uintptr thing, but I think the right change is to do an info
structure. I never liked that code as it was, anyway.
Thanks,
-corey
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning
2025-04-15 19:09 ` Corey Minyard
@ 2025-04-16 6:34 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-16 6:34 UTC (permalink / raw)
To: Corey Minyard
Cc: openipmi-developer, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Tue, Apr 15, 2025 at 02:09:00PM -0500, Corey Minyard wrote:
> On Tue, Apr 15, 2025 at 03:11:56PM +0300, Andy Shevchenko wrote:
> > On Tue, Apr 15, 2025 at 03:06:45PM +0300, Andy Shevchenko wrote:
> > > On Tue, Apr 15, 2025 at 06:39:03AM -0500, Corey Minyard wrote:
> > > > On Tue, Apr 15, 2025 at 11:51:56AM +0300, Andy Shevchenko wrote:
> > > > > Debian clang version 19.1.7 is not happy when compiled with
> > > > > `make W=1` (note, CONFIG_WERROR=y is the default):
> > > > >
> > > > > ipmi_si_platform.c:268:15: error: cast to smaller integer type 'enum si_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
> > > > > 268 | io.si_type = (enum si_type)device_get_match_data(&pdev->dev);
> > > > >
> > > > > Fix this by intermediate cast to the uintptr_t, that makes compiler happy.
> > > >
> > > > Unless things have changed recently, Linus prefers "unsigned long" per
> > > > https://patchwork.kernel.org/project/linux-hardening/patch/20220616143617.449094-1-Jason@zx2c4.com/#24899749
> > >
> > > I'm not sure I got your point. That discussion seems irrelevant to me.
> > > They are talking about pointer-as-an-integer cases. Here we already know
> > > that we are passing integer-as-a-pointer and this is the opposite
> > > conversion.
> > >
> > > > And it would match what is in the match table.
> > >
> > > Match tables are tend to move to pointers, enum is usually goes to int.
> > >
> > > > Is that change ok?
> > >
> > > If you don't like my change, please do yours and consider this as
> > > a bug report that needs to be addressed. I prefer more my solution
> > > as we do that in many places for the exact scenario.
> >
> > Note, the proper solution to the cases like this is to move to info-like
> > structure and actually operate with the pointers instead of enums, longs, etc.
> >
> > That's what's slowly moving on in IIO subsystem, for instance.
>
> Yes, you are right, I'll probably make that change. I'm not sure
> about the uintptr thing, but I think the right change is to do an info
> structure. I never liked that code as it was, anyway.
Please do, I will happily test anything you provide as currently this code breaks
`make W=1` builds.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-16 6:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 8:51 [PATCH v1 1/1] ipmi: si: Cast to smaller integer type without warning Andy Shevchenko
2025-04-15 11:39 ` Corey Minyard
2025-04-15 12:06 ` Andy Shevchenko
2025-04-15 12:11 ` Andy Shevchenko
2025-04-15 19:09 ` Corey Minyard
2025-04-16 6:34 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox