From: "Darrick J. Wong" <djwong@kernel.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH 3/8][next] xfs: Avoid -Wflex-array-member-not-at-end warnings
Date: Mon, 24 Feb 2025 11:12:09 -0800 [thread overview]
Message-ID: <20250224191209.GZ21808@frogsfrogsfrogs> (raw)
In-Reply-To: <e1b8405de7073547ed6252a314fb467680b4c7e8.1739957534.git.gustavoars@kernel.org>
On Mon, Feb 24, 2025 at 08:27:44PM +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 27 of the following warnings:
>
> fs/xfs/xfs_log_priv.h:208:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> fs/xfs/xfs_log.c | 15 +++++++++------
> fs/xfs/xfs_log_priv.h | 2 +-
> 2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index f8851ff835de..7e8b71f64a46 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1245,7 +1245,7 @@ xlog_ioend_work(
> }
>
> xlog_state_done_syncing(iclog);
> - bio_uninit(&iclog->ic_bio);
> + bio_uninit(container_of(&iclog->ic_bio, struct bio, __hdr));
>
> /*
> * Drop the lock to signal that we are done. Nothing references the
> @@ -1663,7 +1663,8 @@ xlog_write_iclog(
> * writeback throttle from throttling log writes behind background
> * metadata writeback and causing priority inversions.
> */
> - bio_init(&iclog->ic_bio, log->l_targ->bt_bdev, iclog->ic_bvec,
> + bio_init(container_of(&iclog->ic_bio, struct bio, __hdr),
> + log->l_targ->bt_bdev, iclog->ic_bvec,
> howmany(count, PAGE_SIZE),
> REQ_OP_WRITE | REQ_META | REQ_SYNC | REQ_IDLE);
> iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno;
> @@ -1692,7 +1693,8 @@ xlog_write_iclog(
>
> iclog->ic_flags &= ~(XLOG_ICL_NEED_FLUSH | XLOG_ICL_NEED_FUA);
>
> - if (xlog_map_iclog_data(&iclog->ic_bio, iclog->ic_data, count))
> + if (xlog_map_iclog_data(container_of(&iclog->ic_bio, struct bio, __hdr),
> + iclog->ic_data, count))
> goto shutdown;
>
> if (is_vmalloc_addr(iclog->ic_data))
> @@ -1705,16 +1707,17 @@ xlog_write_iclog(
> if (bno + BTOBB(count) > log->l_logBBsize) {
> struct bio *split;
>
> - split = bio_split(&iclog->ic_bio, log->l_logBBsize - bno,
> + split = bio_split(container_of(&iclog->ic_bio, struct bio, __hdr),
> + log->l_logBBsize - bno,
> GFP_NOIO, &fs_bio_set);
> - bio_chain(split, &iclog->ic_bio);
> + bio_chain(split, container_of(&iclog->ic_bio, struct bio, __hdr));
> submit_bio(split);
>
> /* restart at logical offset zero for the remainder */
> iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart;
> }
>
> - submit_bio(&iclog->ic_bio);
> + submit_bio(container_of(&iclog->ic_bio, struct bio, __hdr));
> return;
> shutdown:
> xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
> diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
> index f3d78869e5e5..32abc48aef24 100644
> --- a/fs/xfs/xfs_log_priv.h
> +++ b/fs/xfs/xfs_log_priv.h
> @@ -205,7 +205,7 @@ typedef struct xlog_in_core {
> #endif
> struct semaphore ic_sema;
> struct work_struct ic_end_io_work;
> - struct bio ic_bio;
> + struct bio_hdr ic_bio;
What struct is this?
$ git grep 'struct bio_hdr' include/
$
(Please always send the core code change patches to the xfs list.)
--D
> struct bio_vec ic_bvec[];
> } xlog_in_core_t;
>
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2025-02-24 19:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 9:53 [PATCH 0/8][next] Avoid a couple hundred -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-02-24 9:57 ` [PATCH 3/8][next] xfs: Avoid " Gustavo A. R. Silva
2025-02-24 19:12 ` Darrick J. Wong [this message]
2025-02-24 21:45 ` Dave Chinner
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=20250224191209.GZ21808@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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