Re: [PATCH] i2c: pxa: fix clang -Wvoid-pointer-to-enum-cast warning

From: Justin Stitt
Date: Fri Aug 25 2023 - 18:50:49 EST


On Fri, Aug 25, 2023 at 3:17 PM Wolfram Sang <wsa@xxxxxxxxxx> wrote:
>
>
> > Note: I think something like this may be more readable:
> > | *i2c_types = (enum pxa_i2c_types)(uintptr_t)of_id->data;
> >
> > Thoughts on this approach against the one present in this patch?
>
> On the one hand, I think this is more explicit and, thus, more readable.
> On the other hand, we still have the loss of precision, between the
> first and the second cast. Which gives it a bit of a "let's hide it
> somewhat so the compiler will be happy" feeling?
>
There was some discussion [1] wherein it was ultimately decided that
this warning should probably be turned off (contrary to what the title
of the GitHub issue says).

The state of these patches [2] is in some sort of limbo until I get a
patch in to disable the warning from W=1 (keep in mind GCC doesn't
even support this specific warning). I want to make the patch but am
seeking some guidance about what exactly is to be done -- I feel a
simply _demotion_ from W=1 to W=2 would suffice as CI robots aren't
testing w/ that AFAIK.

Nick, do you have anything to add here as we had previously discussed
this off-list/IRL.

[1]: https://github.com/ClangBuiltLinux/linux/issues/1910
[2]: https://lore.kernel.org/all/?q=b%3Apointer-to-enum-cast