Skip to content

Commit 6dfa10a

Browse files
author
Kent Overstreet
committed
bcachefs: Fix build errors with gcc 10
gcc 10 seems to complain about array bounds in situations where gcc 11 does not - curious. This unfortunately requires adding some casts for now; we may investigate getting rid of our __u64 _data[] VLA in a future patch so that our start[0] members can be VLAs. Reported-by: John Stoffel <john@stoffel.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 4db8ac8 commit 6dfa10a

5 files changed

Lines changed: 7 additions & 9 deletions

File tree

fs/bcachefs/bcachefs_format.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,9 +1617,7 @@ struct journal_seq_blacklist_entry {
16171617

16181618
struct bch_sb_field_journal_seq_blacklist {
16191619
struct bch_sb_field field;
1620-
1621-
struct journal_seq_blacklist_entry start[0];
1622-
__u64 _data[];
1620+
struct journal_seq_blacklist_entry start[];
16231621
};
16241622

16251623
struct bch_sb_field_errors {

fs/bcachefs/btree_trans_commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,23 +681,23 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
681681
BCH_JSET_ENTRY_overwrite,
682682
i->btree_id, i->level,
683683
i->old_k.u64s);
684-
bkey_reassemble(&entry->start[0],
684+
bkey_reassemble((struct bkey_i *) entry->start,
685685
(struct bkey_s_c) { &i->old_k, i->old_v });
686686
}
687687

688688
entry = bch2_journal_add_entry(j, &trans->journal_res,
689689
BCH_JSET_ENTRY_btree_keys,
690690
i->btree_id, i->level,
691691
i->k->k.u64s);
692-
bkey_copy(&entry->start[0], i->k);
692+
bkey_copy((struct bkey_i *) entry->start, i->k);
693693
}
694694

695695
trans_for_each_wb_update(trans, wb) {
696696
entry = bch2_journal_add_entry(j, &trans->journal_res,
697697
BCH_JSET_ENTRY_btree_keys,
698698
wb->btree, 0,
699699
wb->k.k.u64s);
700-
bkey_copy(&entry->start[0], &wb->k);
700+
bkey_copy((struct bkey_i *) entry->start, &wb->k);
701701
}
702702

703703
if (trans->journal_seq)

fs/bcachefs/btree_update_interior.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@ void bch2_journal_entry_to_btree_root(struct bch_fs *c, struct jset_entry *entry
24112411

24122412
r->level = entry->level;
24132413
r->alive = true;
2414-
bkey_copy(&r->key, &entry->start[0]);
2414+
bkey_copy(&r->key, (struct bkey_i *) entry->start);
24152415

24162416
mutex_unlock(&c->btree_root_lock);
24172417
}

fs/bcachefs/btree_update_interior.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static inline struct btree_node_entry *want_new_bset(struct bch_fs *c,
271271
struct btree_node_entry *bne = max(write_block(b),
272272
(void *) btree_bkey_last(b, bset_tree_last(b)));
273273
ssize_t remaining_space =
274-
__bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
274+
__bch_btree_u64s_remaining(c, b, bne->keys.start);
275275

276276
if (unlikely(bset_written(b, bset(b, t)))) {
277277
if (remaining_space > (ssize_t) (block_bytes(c) >> 3))

fs/bcachefs/recovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static int journal_replay_entry_early(struct bch_fs *c,
226226

227227
if (entry->u64s) {
228228
r->level = entry->level;
229-
bkey_copy(&r->key, &entry->start[0]);
229+
bkey_copy(&r->key, (struct bkey_i *) entry->start);
230230
r->error = 0;
231231
} else {
232232
r->error = -EIO;

0 commit comments

Comments
 (0)