From: Kalle Valo <kvalo@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, Felix Fietkau <nbd@nbd.name>,
Jeff Johnson <jjohnson@kernel.org>,
ath11k@lists.infradead.org,
Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH] bitfield: suppress "dubious: x & !y" sparse warning
Date: Wed, 28 Feb 2024 11:54:12 +0000 (UTC) [thread overview]
Message-ID: <170912125112.3868947.18107049542995601682.kvalo@kernel.org> (raw)
In-Reply-To: <20240223100146.d243b6b1a9a1.I033828b1187c6bccf086e31400f7e933bb8373e7@changeid>
Johannes Berg <johannes@sipsolutions.net> wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> 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>
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
prev parent reply other threads:[~2024-02-28 11:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 9:01 [PATCH] bitfield: suppress "dubious: x & !y" sparse warning Johannes Berg
2024-02-28 11:54 ` Kalle Valo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170912125112.3868947.18107049542995601682.kvalo@kernel.org \
--to=kvalo@kernel.org \
--cc=ath11k@lists.infradead.org \
--cc=jjohnson@kernel.org \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).