Skip to content

Commit

Permalink
Cleanup: zap_leaf_array_read() should use BSWAP_64()
Browse files Browse the repository at this point in the history
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 <richard.yao@alumni.stonybrook.edu>
  • Loading branch information
ryao committed Nov 20, 2022
1 parent f17b056 commit e4a77bb
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions module/zfs/zap_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit e4a77bb

Please sign in to comment.