History

ext4: 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. Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly. So, with these changes, fix the following warning: fs/ext4/mballoc.c:3041:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Gustavo A. R. Silva committed 1 year ago

Commit 7e50bbb1 parent ce7e8a61 file · +8 −10Browse files

Unified · Split

fs/ext4/mballoc.c+8−10
@@ -3037,10 +3037,8 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) · 3036 unmodified lines
3037 unsigned char blocksize_bits = min_t(unsigned char,3037 unsigned char blocksize_bits = min_t(unsigned char,
3038 sb->s_blocksize_bits,3038 sb->s_blocksize_bits,
3039 EXT4_MAX_BLOCK_LOG_SIZE);3039 EXT4_MAX_BLOCK_LOG_SIZE);
3040 struct sg {3040 DEFINE_RAW_FLEX(struct ext4_group_info, sg, bb_counters,
3041 struct ext4_group_info info;3041 EXT4_MAX_BLOCK_LOG_SIZE + 2);
3042 ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
3043 } sg;
3044 3042
3045 group--;3043 group--;
3046 if (group == 0)3044 if (group == 0)
@@ -3048,7 +3046,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) · 1 unmodified line
3048 " 2^0 2^1 2^2 2^3 2^4 2^5 2^6 "3046 " 2^0 2^1 2^2 2^3 2^4 2^5 2^6 "
3049 " 2^7 2^8 2^9 2^10 2^11 2^12 2^13 ]\n");3047 " 2^7 2^8 2^9 2^10 2^11 2^12 2^13 ]\n");
3050 3048
3051 i = (blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) +3049 i = (blocksize_bits + 2) * sizeof(sg->bb_counters[0]) +
3052 sizeof(struct ext4_group_info);3050 sizeof(struct ext4_group_info);
3053 3051
3054 grinfo = ext4_get_group_info(sb, group);3052 grinfo = ext4_get_group_info(sb, group);
@@ -3068,14 +3066,14 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) · 13 unmodified lines
3068 * We care only about free space counters in the group info and3066 * We care only about free space counters in the group info and
3069 * these are safe to access even after the buddy has been unloaded3067 * these are safe to access even after the buddy has been unloaded
3070 */3068 */
3071 memcpy(&sg, grinfo, i);3069 memcpy(sg, grinfo, i);
3072 seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,3070 seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg->bb_free,
3073 sg.info.bb_fragments, sg.info.bb_first_free);3071 sg->bb_fragments, sg->bb_first_free);
3074 for (i = 0; i <= 13; i++)3072 for (i = 0; i <= 13; i++)
3075 seq_printf(seq, " %-5u", i <= blocksize_bits + 1 ?3073 seq_printf(seq, " %-5u", i <= blocksize_bits + 1 ?
3076 sg.info.bb_counters[i] : 0);3074 sg->bb_counters[i] : 0);
3077 seq_puts(seq, " ]");3075 seq_puts(seq, " ]");
3078 if (EXT4_MB_GRP_BBITMAP_CORRUPT(&sg.info))3076 if (EXT4_MB_GRP_BBITMAP_CORRUPT(sg))
3079 seq_puts(seq, " Block bitmap corrupted!");3077 seq_puts(seq, " Block bitmap corrupted!");
3080 seq_putc(seq, '\n');3078 seq_putc(seq, '\n');
3081 return 0;3079 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t