From: Ping-Ke Shih <pkshih@realtek.com>
To: Su Hui <suhui@nfschina.com>,
"dan.carpenter@linaro.org" <dan.carpenter@linaro.org>,
"kvalo@kernel.org" <kvalo@kernel.org>,
"nathan@kernel.org" <nathan@kernel.org>,
"ndesaulniers@google.com" <ndesaulniers@google.com>,
"trix@redhat.com" <trix@redhat.com>
Cc: "lizetao1@huawei.com" <lizetao1@huawei.com>,
"linville@tuxdriver.com" <linville@tuxdriver.com>,
"Larry.Finger@lwfinger.net" <Larry.Finger@lwfinger.net>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: RE: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior
Date: Fri, 24 Nov 2023 08:51:15 +0000 [thread overview]
Message-ID: <167fbc7a77db447d90f696666f6f0a9b@realtek.com> (raw)
In-Reply-To: <20231124020352.1660621-2-suhui@nfschina.com>
> -----Original Message-----
> From: Su Hui <suhui@nfschina.com>
> Sent: Friday, November 24, 2023 10:04 AM
> To: dan.carpenter@linaro.org; Ping-Ke Shih <pkshih@realtek.com>; kvalo@kernel.org; nathan@kernel.org;
> ndesaulniers@google.com; trix@redhat.com
> Cc: Su Hui <suhui@nfschina.com>; lizetao1@huawei.com; linville@tuxdriver.com; Larry.Finger@lwfinger.net;
> linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org; llvm@lists.linux.dev;
> kernel-janitors@vger.kernel.org
> Subject: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior
>
[...]
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> index 6df270e29e66..52ab1b0761c0 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> @@ -31,7 +31,12 @@ static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask)
> {
> u32 i = ffs(bitmask);
>
> - return i ? i - 1 : 32;
> + if (!i) {
> + WARN_ON_ONCE(1);
> + return 0;
> + }
> +
> + return i - 1;
> }
Personally, I prefer to use __ffs(), because in normal case no need additional '-1',
and abnormal cases should not happen.
next prev parent reply other threads:[~2023-11-24 8:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 2:03 [PATCH v2 1/2] wifi: rtlwifi: rtl8821ae: phy: remove some useless code Su Hui
2023-11-24 2:03 ` [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior Su Hui
2023-11-24 8:51 ` Ping-Ke Shih [this message]
2023-11-24 10:06 ` Su Hui
2023-11-24 11:19 ` Ping-Ke Shih
2023-11-27 1:13 ` Su Hui
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=167fbc7a77db447d90f696666f6f0a9b@realtek.com \
--to=pkshih@realtek.com \
--cc=Larry.Finger@lwfinger.net \
--cc=dan.carpenter@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=lizetao1@huawei.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=suhui@nfschina.com \
--cc=trix@redhat.com \
/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