Skip to content

Commit 53cf2a3

Browse files
author
Kent Overstreet
committed
bcachefs: Fix kmsan warnings in bch2_extent_crc_pack()
We store to all fields, so the kmsan warnings were spurious - but initializing via stores to bitfields appear to have been giving the compiler/kmsan trouble, and they're not necessary. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 9c3a2c9 commit 53cf2a3

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

fs/bcachefs/extents.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -592,29 +592,35 @@ static void bch2_extent_crc_pack(union bch_extent_crc *dst,
592592
struct bch_extent_crc_unpacked src,
593593
enum bch_extent_entry_type type)
594594
{
595-
#define set_common_fields(_dst, _src) \
596-
_dst.type = 1 << type; \
597-
_dst.csum_type = _src.csum_type, \
598-
_dst.compression_type = _src.compression_type, \
599-
_dst._compressed_size = _src.compressed_size - 1, \
600-
_dst._uncompressed_size = _src.uncompressed_size - 1, \
601-
_dst.offset = _src.offset
595+
#define common_fields(_src) \
596+
.type = BIT(type), \
597+
.csum_type = _src.csum_type, \
598+
.compression_type = _src.compression_type, \
599+
._compressed_size = _src.compressed_size - 1, \
600+
._uncompressed_size = _src.uncompressed_size - 1, \
601+
.offset = _src.offset
602602

603603
switch (type) {
604604
case BCH_EXTENT_ENTRY_crc32:
605-
set_common_fields(dst->crc32, src);
606-
dst->crc32.csum = (u32 __force) *((__le32 *) &src.csum.lo);
605+
dst->crc32 = (struct bch_extent_crc32) {
606+
common_fields(src),
607+
.csum = (u32 __force) *((__le32 *) &src.csum.lo),
608+
};
607609
break;
608610
case BCH_EXTENT_ENTRY_crc64:
609-
set_common_fields(dst->crc64, src);
610-
dst->crc64.nonce = src.nonce;
611-
dst->crc64.csum_lo = (u64 __force) src.csum.lo;
612-
dst->crc64.csum_hi = (u64 __force) *((__le16 *) &src.csum.hi);
611+
dst->crc64 = (struct bch_extent_crc64) {
612+
common_fields(src),
613+
.nonce = src.nonce,
614+
.csum_lo = (u64 __force) src.csum.lo,
615+
.csum_hi = (u64 __force) *((__le16 *) &src.csum.hi),
616+
};
613617
break;
614618
case BCH_EXTENT_ENTRY_crc128:
615-
set_common_fields(dst->crc128, src);
616-
dst->crc128.nonce = src.nonce;
617-
dst->crc128.csum = src.csum;
619+
dst->crc128 = (struct bch_extent_crc128) {
620+
common_fields(src),
621+
.nonce = src.nonce,
622+
.csum = src.csum,
623+
};
618624
break;
619625
default:
620626
BUG();

0 commit comments

Comments
 (0)