mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: dsterba@suse.cz, "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
Date: Fri, 3 Oct 2025 15:51:24 +0100	[thread overview]
Message-ID: <b59ed01f-d9d5-4de8-8a12-1e506962b2d9@embeddedor.com> (raw)
In-Reply-To: <20251003143502.GJ4052@suse.cz>



On 10/3/25 15:35, David Sterba wrote:
> On Fri, Oct 03, 2025 at 03:11:06PM +0100, 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.
>>
>> Move the conflicting declaration to the end of the corresponding
>> structure. Notice that `struct fs_path` is a flexible structure,
>> this is a structure that contains a flexible-array member (`char
>> inline_buf[];` in this case).
> 
> It contains a flexible member but also a padding array and a limit
> calculated for the usable space of inline_buf (FS_PATH_INLINE_SIZE),
> it's not the pattern where flexible array is in the middle of a
> structure and could potentially overwrite other members.

Yep, I notice that while reviewing the context in which this is being
used. :)

> 
>> Fix the following warning:
>>
>> fs/btrfs/send.c:181:24: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 
> Otheriwse OK to fix the warning.

Thanks.

> 
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> ---
>>   fs/btrfs/send.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
>> index 9230e5066fc6..2b7cf49a35bb 100644
>> --- a/fs/btrfs/send.c
>> +++ b/fs/btrfs/send.c
>> @@ -178,7 +178,6 @@ struct send_ctx {
>>   	u64 cur_inode_rdev;
>>   	u64 cur_inode_last_extent;
>>   	u64 cur_inode_next_write_offset;
>> -	struct fs_path cur_inode_path;
>>   	bool cur_inode_new;
>>   	bool cur_inode_new_gen;
>>   	bool cur_inode_deleted;
>> @@ -305,6 +304,9 @@ struct send_ctx {
>>   
>>   	struct btrfs_lru_cache dir_created_cache;
>>   	struct btrfs_lru_cache dir_utimes_cache;
>> +
>> +	/* Must be last --ends in a flexible-array member. */
>                          ^^
> 
> Is this an en dash?

Not sure what you mean.

-Gustavo

> 
>> +	struct fs_path cur_inode_path;
>>   };
>>   
>>   struct pending_dir_move {
>> -- 
>> 2.43.0
>>



  reply	other threads:[~2025-10-03 14:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-03 14:11 Gustavo A. R. Silva
2025-10-03 14:35 ` David Sterba
2025-10-03 14:51   ` Gustavo A. R. Silva [this message]
2025-10-03 15:15     ` David Sterba
2025-10-03 15:21       ` Gustavo A. R. Silva
2025-10-06 16:06         ` David Sterba
2025-10-06 17:23 ` David Sterba

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=b59ed01f-d9d5-4de8-8a12-1e506962b2d9@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=gustavoars@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®