From: Andy Shevchenko <andy@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Cosmin Tanislav <cosmin.tanislav@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Michael Walle <michael@walle.cc>, Nuno Sa <nuno.sa@analog.com>,
Dumitru Ceclan <mitrutzceclan@gmail.com>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: adc: ad7173: Fix comparison of channel configs
Date: Thu, 30 Jan 2025 20:11:08 +0200 [thread overview]
Message-ID: <Z5vAvO1jD0K29FmY@smile.fi.intel.com> (raw)
In-Reply-To: <aa397f3749403477ee4a8f416b5890099f430ca5.1738258777.git.u.kleine-koenig@baylibre.com>
On Thu, Jan 30, 2025 at 06:45:02PM +0100, Uwe Kleine-König wrote:
> Checking the binary representation of two structs (of the same type)
> for equality doesn't have the same semantic as comparing all members for
> equality. The former might find a difference where the latter doesn't in
> the presence of padding or when ambiguous types like float or bool are
> involved. (Floats typically have different representations for single
> values, like -0.0 vs +0.0, or 0.5 * 2² vs 0.25 * 2³. The type bool has
> at least 8 bits and the raw values 1 and 2 (probably) both evaluate to
> true, but memcmp finds a difference.)
memcmp()
> When searching for a channel that already has the configuration we need,
> the comparison by member is the one that is needed.
>
> Convert the comparison accordingly to compare the members one after
> another. Also add a BUILD_BUG guard to (somewhat) ensure that when
static_assert() will give a better messaging.
> struct ad7173_channel_config::config_props is expanded, the comparison
> is adapted, too.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2025-01-30 18:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 17:45 [PATCH 0/2] iio: adc: ad*: Fix comparisons using memcmp Uwe Kleine-König
2025-01-30 17:45 ` [PATCH 1/2] iio: adc: ad4130: Fix comparison of channel setups Uwe Kleine-König
2025-01-30 18:08 ` Andy Shevchenko
2025-01-30 18:14 ` Andy Shevchenko
2025-02-12 9:01 ` Uwe Kleine-König
2025-02-13 14:14 ` Nuno Sá
2025-01-30 17:45 ` [PATCH 2/2] iio: adc: ad7173: Fix comparison of channel configs Uwe Kleine-König
2025-01-30 18:11 ` Andy Shevchenko [this message]
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=Z5vAvO1jD0K29FmY@smile.fi.intel.com \
--to=andy@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=cosmin.tanislav@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=michael@walle.cc \
--cc=mitrutzceclan@gmail.com \
--cc=nuno.sa@analog.com \
--cc=u.kleine-koenig@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.