Search Linux Wireless

Re: [PATCH] bitfield: suppress "dubious: x & !y" sparse warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Berg <johannes@xxxxxxxxxxxxxxxx> wrote:

> From: Johannes Berg <johannes.berg@xxxxxxxxx>
> 
> 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@xxxxxxxxx>

Patch applied to wireless-next.git, thanks.

416eb60317c6 bitfield: suppress "dubious: x & !y" sparse warning

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20240223100146.d243b6b1a9a1.I033828b1187c6bccf086e31400f7e933bb8373e7@changeid/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches





[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux