Re: [PATCH 6/8][next] nvme: target: Avoid -Wflex-array-member-not-at-end warnings

From: Gustavo A. R. Silva
Date: Mon Feb 24 2025 - 20:51:40 EST




On 25/02/25 00:49, Christoph Hellwig wrote:
On Mon, Feb 24, 2025 at 08:30:10PM +1030, Gustavo A. R. Silva wrote:
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Change the type of the middle struct members currently causing trouble
from `struct bio` to `struct bio_hdr`.

We also use `container_of()` whenever we need to retrieve a pointer to
the flexible structure `struct bio`, through which we can access the
flexible-array member in it, if necessary.

With these changes fix 38 of the following warnings:

drivers/nvme/target/nvmet.h:455:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/nvme/target/nvmet.h:462:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]


I'm not sure where you bio_hdr structure comes from, but maybe that's
because you annoyingly split CC over the series, and by the number of
patches probably also bundled unrelated changes.

Ugh, yes, I messed up my script just before creating the series.


In general our first resort here should be to move embedded bio to the
of containing structures. If that's not possible you'll need to explain
why.


Yes. Also, thanks for the feedback in your other response. I'll try to
follow that approach and see how it goes.

--
Gustavo