From e4a77bb13650ae94258c85f1762bb41db07bf29a Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Sun, 20 Nov 2022 18:22:01 -0500 Subject: [PATCH] Cleanup: zap_leaf_array_read() should use BSWAP_64() We neuter the byteswap macros in Coverity builds to suppress Coverity complaints about byteswapped data being tainted. However, this does not apply to functions that hardcode byteswapping such as `zap_leaf_array_read()`. We modify `zap_leaf_array_read()` to use `BSWAP_64()`. This suppresses Coverity's complaints and makes the code slightly more succinct. Reported-by: Coverity (CID 1524543) Signed-off-by: Richard Yao --- module/zfs/zap_leaf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/module/zfs/zap_leaf.c b/module/zfs/zap_leaf.c index 2e8489c7dfcf..38bdef17648b 100644 --- a/module/zfs/zap_leaf.c +++ b/module/zfs/zap_leaf.c @@ -288,13 +288,9 @@ zap_leaf_array_read(zap_leaf_t *l, uint16_t chunk, /* Fast path for one 8-byte integer */ if (array_int_len == 8 && buf_int_len == 8 && len == 1) { struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; - uint8_t *ip = la->la_array; uint64_t *buf64 = buf; - *buf64 = (uint64_t)ip[0] << 56 | (uint64_t)ip[1] << 48 | - (uint64_t)ip[2] << 40 | (uint64_t)ip[3] << 32 | - (uint64_t)ip[4] << 24 | (uint64_t)ip[5] << 16 | - (uint64_t)ip[6] << 8 | (uint64_t)ip[7]; + *buf64 = BSWAP_64(*(uint64_t *)la->la_array); return; }