diff options
author | Johannes Berg <johannes.berg@intel.com> | 2024-02-23 10:01:46 +0100 |
---|---|---|
committer | Kalle Valo <kvalo@kernel.org> | 2024-02-28 13:53:39 +0200 |
commit | 416eb60317c64676d158dffea150762930ec008f (patch) | |
tree | 6f94b9fe5c6fd25e408ef1ff9783241aabbcd31a /net/mac80211 | |
parent | a7e178259c5bc900da762b33d3a20b7ee1206f07 (diff) |
bitfield: suppress "dubious: x & !y" sparse warning
There's a somewhat common pattern of using FIELD_PREP()
even for single bits, e.g.
cmd->info1 |= FIELD_PREP(HTT_SRNG_SETUP_CMD_INFO1_RING_FLAGS_MSI_SWAP,
!!(params.flags & HAL_SRNG_FLAGS_MSI_SWAP));
which might as well be written as
if (params.flags & HAL_SRNG_FLAGS_MSI_SWAP)
cmd->info1 |= HTT_SRNG_SETUP_CMD_INFO1_RING_FLAGS_MSI_SWAP;
(since info1 is fully initialized to start with), but in
a long chain of FIELD_PREP() this really seems fine.
However, it triggers a sparse warning, in the check in
the macro for whether a constant value fits into the mask,
as this contains a "& (_val)". In this case, this really
is always intentional, so just suppress the warning by
adding "0+" to the expression, indicating explicitly that
this is correct.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240223100146.d243b6b1a9a1.I033828b1187c6bccf086e31400f7e933bb8373e7@changeid
Diffstat (limited to 'net/mac80211')
0 files changed, 0 insertions, 0 deletions