btrfs: Avoid -Wflex-array-member-not-at-end warning
PATCH 1/1 btrfs: Avoid -Wflex-array-member-not-at-end warning
-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]
--- fs/btrfs/send.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/send.c +3 -1
@@ -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 {
Signature · 1 line
2.43.0
Quoted 7 lines · Gustavo A. R. Silva
-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_pathis 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.
Quoted 3 lines
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.
Quoted 18 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>--- fs/btrfs/send.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/btrfs/send.c +0
-1@@ -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;
fs/btrfs/send.c struct send_ctx { · line 308
Quoted 5 lines
fs/btrfs/send.c +2
-0@@ -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?
Quoted 7 lines
fs/btrfs/send.c +1
-0+struct fs_path cur_inode_path; };struct pending_dir_move {Signature · 1 line
2.43.0
Quoted 9 lines · David Sterba
Quoted 7 lines · Gustavo A. R. Silva
-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_pathis a flexible structure, this is a structure that contains a flexible-array member (char inline_buf[];in this case).
Quoted 4 lines
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. :)
Quoted 6 lines
Quoted 4 lines
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.
Quoted 20 lines
Quoted 20 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>--- fs/btrfs/send.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/btrfs/send.c +0
-1@@ -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 {
Quoted 7 lines
fs/btrfs/send.c struct send_ctx { · line 308
Quoted 4 lines
fs/btrfs/send.c +2
-0struct 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
Quoted 8 lines
Quoted 8 lines
fs/btrfs/send.c +1
-0+struct fs_path cur_inode_path; };struct pending_dir_move {Signature · 1 line
2.43.0
Quoted 21 lines · Gustavo A. R. Silva
Quoted 21 lines
Quoted 14 lines
fs/btrfs/send.c +0
-1@@ -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;fs/btrfs/send.c struct send_ctx { · line 308
Quoted 5 lines
fs/btrfs/send.c +2
-0@@ -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. */ ^^
Quoted 3 lines
Quoted 1 line
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.
Quoted 22 lines · David Sterba
Quoted 21 lines · Gustavo A. R. Silva
Quoted 21 lines
Quoted 14 lines
fs/btrfs/send.c +0
-1@@ -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;fs/btrfs/send.c struct send_ctx { · line 308
Quoted 5 lines
fs/btrfs/send.c +2
-0@@ -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. */ ^^
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
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
Quoted 23 lines · Gustavo A. R. Silva
Quoted 22 lines · David Sterba
Quoted 21 lines · Gustavo A. R. Silva
Quoted 21 lines
Quoted 14 lines
fs/btrfs/send.c +0
-1@@ -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;fs/btrfs/send.c struct send_ctx { · line 308
Quoted 5 lines
fs/btrfs/send.c +2
-0@@ -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. */ ^^
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
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.
Quoted 8 lines · Gustavo A. R. Silva
-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_pathis a flexible structure, this is a structure that contains a flexible-array member (char inline_buf[];in this case).
Quoted 5 lines
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 <[email protected]>
Added to for-next, with updated changelog. Thanks.