From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-iio@vger.kernel.org, "Peter Rosin" <peda@axentia.se>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: iio-mux: use flexible array member
Date: Mon, 16 Mar 2026 23:24:17 +0200 [thread overview]
Message-ID: <abh1AI4sjm15z1by@ashevche-desk.local> (raw)
In-Reply-To: <CAKxU2N8xj_SX7W0KncyeJ7NeL+kuyfkQ5zzrTj9Dipt8rTJMjA@mail.gmail.com>
On Mon, Mar 16, 2026 at 02:12:35PM -0700, Rosen Penev wrote:
> On Mon, Mar 16, 2026 at 12:43 PM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Mon, Mar 16, 2026 at 11:11:22AM -0700, Rosen Penev wrote:
> > > On Mon, Mar 16, 2026 at 7:16 AM Andy Shevchenko
> > > <andriy.shevchenko@intel.com> wrote:
> > > > On Sun, Mar 15, 2026 at 03:45:09PM -0700, Rosen Penev wrote:
...
> > > > > - sizeof_priv = sizeof(*mux);
> > > > > - sizeof_priv += sizeof(*mux->child) * children;
> > > > > + sizeof_priv = struct_size(mux, child, children);
> > > > > sizeof_priv += sizeof(*mux->chan) * children;
> > > >
> > > > There are two arrays that are allocated at the end of the same object.
> > > > Why is mux better than the chan?
> > > It's how it's already laid out. mux first and then the other data.
> >
> > It doesn't matter, right?
> I can't really judge. This commit came from running
>
> git grep \\\*\)\ | grep \ \+\ 1\)\;
>
> which is the pre-C99 way of doing trailing allocations.
>
> Shuffling this around would increase the patch size which I've been
> advised against doing elsewhere.
My point was to show that from the memory layout the mux first chan next and
vice versa have no differences. Hence the proposed patch actually changes the
status quo. What I suggested is to keep a status quo and use array_size()
instead.
sizeof_priv = sizeof(mux);
sizeof_priv += array_size(child);
sizeof_priv += array_size(chan);
> > > > I rather would see two times array_size() than the above.
> >
> > > OK
> >
> > > > > sizeof_priv += sizeof_ext_info;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-03-16 21:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 22:45 Rosen Penev
2026-03-16 14:16 ` Andy Shevchenko
2026-03-16 18:11 ` Rosen Penev
2026-03-16 19:43 ` Andy Shevchenko
2026-03-16 21:12 ` Rosen Penev
2026-03-16 21:24 ` 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=abh1AI4sjm15z1by@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=peda@axentia.se \
--cc=rosenp@gmail.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
all inboxes | Powered by JetHome®