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
30373037 unsigned char blocksize_bits = min_t(unsigned char,
30383038 sb->s_blocksize_bits,
30393039 EXT4_MAX_BLOCK_LOG_SIZE);
3040− struct sg {
3041− struct ext4_group_info info;
3042− ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
3043− } sg;
3040+ DEFINE_RAW_FLEX(struct ext4_group_info, sg, bb_counters,
3041+ EXT4_MAX_BLOCK_LOG_SIZE + 2);
30443042
30453043 group--;
30463044 if (group == 0)
@@ -3048,7 +3046,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) · 1 unmodified line
30483046 " 2^0 2^1 2^2 2^3 2^4 2^5 2^6 "
30493047 " 2^7 2^8 2^9 2^10 2^11 2^12 2^13 ]\n");
30503048
3051− i = (blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) +
3049+ i = (blocksize_bits + 2) * sizeof(sg->bb_counters[0]) +
30523050 sizeof(struct ext4_group_info);
30533051
30543052 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
30683066 * We care only about free space counters in the group info and
30693067 * these are safe to access even after the buddy has been unloaded
30703068 */
3071− memcpy(&sg, grinfo, i);
3072− seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
3073− sg.info.bb_fragments, sg.info.bb_first_free);
3069+ memcpy(sg, grinfo, i);
3070+ seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg->bb_free,
3071+ sg->bb_fragments, sg->bb_first_free);
30743072 for (i = 0; i <= 13; i++)
30753073 seq_printf(seq, " %-5u", i <= blocksize_bits + 1 ?
3076− sg.info.bb_counters[i] : 0);
3074+ sg->bb_counters[i] : 0);
30773075 seq_puts(seq, " ]");
3078− if (EXT4_MB_GRP_BBITMAP_CORRUPT(&sg.info))
3076+ if (EXT4_MB_GRP_BBITMAP_CORRUPT(sg))
30793077 seq_puts(seq, " Block bitmap corrupted!");
30803078 seq_putc(seq, '\n');
30813079 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