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 1/2] iio: adc: ad4130: Fix comparison of channel setups
Date: Thu, 30 Jan 2025 20:14:39 +0200 [thread overview]
Message-ID: <Z5vBj62990oPT0QK@smile.fi.intel.com> (raw)
In-Reply-To: <584b8bae1ad158fc86bd1cd9bd3dcae54b58093e.1738258777.git.u.kleine-koenig@baylibre.com>
On Thu, Jan 30, 2025 at 06:45:01PM +0100, Uwe Kleine-König wrote:
...
> + BUILD_BUG_ON(sizeof(*a) !=
> + sizeof(struct {
> + unsigned int iout0_val;
> + unsigned int iout1_val;
> + unsigned int burnout;
> + unsigned int pga;
> + unsigned int fs;
> + u32 ref_sel;
> + enum ad4130_filter_mode filter_mode;
> + bool ref_bufp;
> + bool ref_bufm;
> + }));
Is I shuffle the fields (for whatever reason) this may give false positive
warnings. I think this BUILD_BUG_ON() is unreliable and ugly looking
(static_assert() won't help much here either), so on the second though I think
it's better to simply add a comments in both places (here and near to the
structure definition) to explain that these needs to be in sync.
> + if (a->iout0_val != b->iout0_val ||
> + a->iout1_val != b->iout1_val ||
> + a->burnout != b->burnout ||
> + a->pga != b->pga ||
> + a->fs != b->fs ||
> + a->ref_sel != b->ref_sel ||
> + a->filter_mode != b->filter_mode ||
> + a->ref_bufp != b->ref_bufp ||
> + a->ref_bufm != b->ref_bufm)
> + return false;
> +
> + return true;
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-01-30 18:14 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 [this message]
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
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=Z5vBj62990oPT0QK@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.