All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
@ 2025-10-03 14:11 Gustavo A. R. Silva
  2025-10-03 14:35 ` David Sterba
  2025-10-06 17:23 ` David Sterba
  0 siblings, 2 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2025-10-03 14:11 UTC (permalink / raw)
  To: Chris Mason, David Sterba
  Cc: linux-btrfs, linux-kernel, Gustavo A. R. Silva, linux-hardening

-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).

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]

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. */
+	struct fs_path cur_inode_path;
 };
 
 struct pending_dir_move {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
  2025-10-03 14:11 [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2025-10-03 14:35 ` David Sterba
  2025-10-03 14:51   ` Gustavo A. R. Silva
  2025-10-06 17:23 ` David Sterba
  1 sibling, 1 reply; 7+ messages in thread
From: David Sterba @ 2025-10-03 14:35 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	linux-hardening

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.

> 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.

> 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?

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
  2025-10-03 14:35 ` David Sterba
@ 2025-10-03 14:51   ` Gustavo A. R. Silva
  2025-10-03 15:15     ` David Sterba
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2025-10-03 14:51 UTC (permalink / raw)
  To: dsterba, Gustavo A. R. Silva
  Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	linux-hardening



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
>>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
  2025-10-03 14:51   ` Gustavo A. R. Silva
@ 2025-10-03 15:15     ` David Sterba
  2025-10-03 15:21       ` Gustavo A. R. Silva
  0 siblings, 1 reply; 7+ messages in thread
From: David Sterba @ 2025-10-03 15:15 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Gustavo A. R. Silva, Chris Mason, David Sterba, linux-btrfs,
	linux-kernel, linux-hardening

On Fri, Oct 03, 2025 at 03:51:24PM +0100, Gustavo A. R. Silva wrote:
> >>
> >> 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.

En dash is a punctuation mark not typically used in comments, nowadays
found in AI generated code/text. I was just curious.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
  2025-10-03 15:15     ` David Sterba
@ 2025-10-03 15:21       ` Gustavo A. R. Silva
  2025-10-06 16:06         ` David Sterba
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2025-10-03 15:21 UTC (permalink / raw)
  To: dsterba
  Cc: Gustavo A. R. Silva, Chris Mason, David Sterba, linux-btrfs,
	linux-kernel, linux-hardening



On 10/3/25 16:15, David Sterba wrote:
> On Fri, Oct 03, 2025 at 03:51:24PM +0100, Gustavo A. R. Silva wrote:
>>>>
>>>> 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.
> 
> En dash is a punctuation mark not typically used in comments, nowadays
> found in AI generated code/text. I was just curious.

Ah yes, I've been using this punctuation mark for this sorts of comments,
but this is not AI generated code/text.

-Gustavo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
  2025-10-03 15:21       ` Gustavo A. R. Silva
@ 2025-10-06 16:06         ` David Sterba
  0 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2025-10-06 16:06 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: dsterba, Gustavo A. R. Silva, Chris Mason, David Sterba,
	linux-btrfs, linux-kernel, linux-hardening

On Fri, Oct 03, 2025 at 04:21:17PM +0100, Gustavo A. R. Silva wrote:
> On 10/3/25 16:15, David Sterba wrote:
> > On Fri, Oct 03, 2025 at 03:51:24PM +0100, Gustavo A. R. Silva wrote:
> >>>>
> >>>> 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.
> > 
> > En dash is a punctuation mark not typically used in comments, nowadays
> > found in AI generated code/text. I was just curious.
> 
> Ah yes, I've been using this punctuation mark for this sorts of comments,

It's quite odd to see it formatted like that, it's confusing and looks
like a typo. The emdash "---" looks like the right punct. mark as it
separates extra information, if we'd want to delve into typographical
conventions.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning
  2025-10-03 14:11 [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
  2025-10-03 14:35 ` David Sterba
@ 2025-10-06 17:23 ` David Sterba
  1 sibling, 0 replies; 7+ messages in thread
From: David Sterba @ 2025-10-06 17:23 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel,
	linux-hardening

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).
> 
> 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]
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Added to for-next, with updated changelog. Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-06 17:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03 14:11 [PATCH][next] btrfs: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-10-03 14:35 ` David Sterba
2025-10-03 14:51   ` Gustavo A. R. Silva
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.