From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Robert Budai" <robert.budai@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: imu: adis16550: rework clock range test
Date: Wed, 2 Jul 2025 16:31:26 +0100 [thread overview]
Message-ID: <20250702163126.000007ac@huawei.com> (raw)
In-Reply-To: <aGVNhIwn7CXO_lpP@smile.fi.intel.com>
On Wed, 2 Jul 2025 18:17:24 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Wed, Jul 02, 2025 at 10:07:17AM -0500, David Lechner wrote:
> > On 7/2/25 9:59 AM, Andy Shevchenko wrote:
> > > On Wed, Jul 02, 2025 at 05:53:57PM +0300, Andy Shevchenko wrote:
> > >> On Wed, Jul 02, 2025 at 09:27:45AM -0500, David Lechner wrote:
> > >>> Rework the clock rate range test to test if sync_mode_data != NULL
> > >>> instead of testing if the for loop index variable. This makes it easier
> > >>> for static analyzers to see that we aren't using an uninitialized
> > >>> sync_mode_data [1].
> > >>
> > >> But at the same time it makes it not to be the usual pattern.,,
> > >
> > > Reading the static analyser output I think the first hunk is only what we need,
> > > but this is still false positive and it's problem of that static
> > > analyser. Have you filed a bug there? (My point is that modifying the code for
> > > the advantage of false positives of some static analyser is wrong road to go
> > > in my opinion.)
> >
> > I agree that we shouldn't fix this _only_ to make the static analyzer
> > happy. But I had to think quite a bit harder to see that the existing
> > code was correct compared to what I have proposed here.
> >
> > But if this is a common pattern that I just haven't learned to identify
> > at a glance yet and everybody else can easily see that the existing code
> > is correct, then perhaps it isn't worth the change.
>
> To me checking against index variable (when it's integer, obviously) is correct
> thing to do and regular pattern. OTOH, if the "index" is a pointer and rather
> we call it "iterator", the angle of view is different because in some cases
> it may lead to stale or invalid value which might be mistakenly dereferenced or
> speculated (see more in the discussion about list entry APIs [entry is a
> keyword here] and if list_entry_is_head() is a good approach.)
>
Original code looks fine to me and is a very common pattern. So I'd argue
the static analyzer needs some work.
Jonathan
next prev parent reply other threads:[~2025-07-02 15:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 14:27 [PATCH] iio: imu: adis16550: rework clock range test David Lechner
2025-07-02 14:53 ` Andy Shevchenko
2025-07-02 14:59 ` Andy Shevchenko
2025-07-02 15:07 ` David Lechner
2025-07-02 15:17 ` Andy Shevchenko
2025-07-02 15:31 ` Jonathan Cameron [this message]
2025-07-02 15:48 ` David Lechner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250702163126.000007ac@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robert.budai@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox