[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOd=1otHgNkJf7wBajDrGmRNQduvR5ie_XgJMPPWT6+n_mQ@mail.gmail.com>
Date: Fri, 25 Aug 2023 15:52:39 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Justin Stitt <justinstitt@...gle.com>
Cc: Wolfram Sang <wsa@...nel.org>, Andi Shyti <andi.shyti@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Tom Rix <trix@...hat.com>, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] i2c: pxa: fix clang -Wvoid-pointer-to-enum-cast warning
On Fri, Aug 25, 2023 at 3:49 PM Justin Stitt <justinstitt@...gle.com> wrote:
>
> On Fri, Aug 25, 2023 at 3:17 PM Wolfram Sang <wsa@...nel.org> 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.
Mostly that we should make -fsanitize=enum not totally suck (i.e.
actually do anything for C code, then check for bad conversions from
values that aren't valid enumeration values including truncations),
then disable this warning in favor of folks testing with that
sanitizer enabled.
>
> [1]: https://github.com/ClangBuiltLinux/linux/issues/1910
> [2]: https://lore.kernel.org/all/?q=b%3Apointer-to-enum-cast
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists