From: Halil Pasic <pasic@linux.ibm.com>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Tony Krowiak <akrowiak@linux.ibm.com>,
Jason Herne <jjherne@linux.ibm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Holger Dengler <dengler@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
linux-hardening@vger.kernel.org, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org, Halil Pasic <pasic@linux.ibm.com>
Subject: Re: [PATCH] s390/vfio-ap: Replace one-element array with flexible array member
Date: Wed, 29 Jan 2025 21:38:26 +0100 [thread overview]
Message-ID: <20250129213826.291cfe12.pasic@linux.ibm.com> (raw)
In-Reply-To: <20250116131859.105756-2-thorsten.blum@linux.dev>
On Thu, 16 Jan 2025 14:18:59 +0100
Thorsten Blum <thorsten.blum@linux.dev> wrote:
> Replace the deprecated one-element array with a modern flexible array
> member in the struct ap_matrix_dev.
>
I'm not sure I understand the value of this. What we have here is not
a flexible array but a one element array. Something that in the generic
case could be many but particularly for vfio-ap is always one.
Imagine if we had exactly 2 supported mdev types. I guess you would not
come to the idea that the array of two needs to be changed to a modern
flexible array. Or am I wrong about that?
So I suppose the problem here is that arrays of one are under general
suspicion of not actually being arrays of one but a pre C99 way of
doing flexible arrays. I kind of do understand that an array wih
one element is funny. But I think the current declaration of
struct ap_matrix_dev is more expressive the proposed one.
Now I understand that it is easy to grep for [1], but it is much
harder to tell.
I've checked in Documentation/process/coding-style.rst did not see this
documented. But then I checked in checkpatch.pl and it indeed seems to
warn about it and refer to
https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
But as far as I can tell it is also talking about the case where one
needs a trailing array of an at compile time unknown size, and not
about the case where all we need is just one element and it happens
to be convenient to have it in an array.
If there is community consensus that one sized arrays are bad regardless
of what they are used for, then the one sized array has to go.
But please tell me what speaks against replacing it with a single
pointer and then taking passing in that pointers address into
mdev_register_parent()?
> Use struct_size() to calculate the number of bytes to allocate for
> matrix_dev with a single mdev_type.
>
> Link: https://github.com/KSPP/linux/issues/79
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
next prev parent reply other threads:[~2025-01-29 20:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 13:18 [PATCH] s390/vfio-ap: Replace one-element array with flexible array member Thorsten Blum
2025-01-28 13:56 ` Alexander Gordeev
2025-01-29 14:27 ` Anthony Krowiak
2025-01-29 15:53 ` Alexander Gordeev
2025-01-29 20:38 ` Halil Pasic [this message]
2025-01-30 0:00 ` Gustavo A. R. Silva
2025-01-30 10:46 ` Halil Pasic
2025-01-30 11:37 ` Alexander Gordeev
2025-01-30 12:46 ` Heiko Carstens
2025-01-31 8:06 ` Halil Pasic
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=20250129213826.291cfe12.pasic@linux.ibm.com \
--to=pasic@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=dengler@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=thorsten.blum@linux.dev \
/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