mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Su Hui <suhui@nfschina.com>
To: Ping-Ke Shih <pkshih@realtek.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 18:06:11 +0800	[thread overview]
Message-ID: <cb551005-eff0-1391-92a0-d956b3d2b930@nfschina.com> (raw)
In-Reply-To: <167fbc7a77db447d90f696666f6f0a9b@realtek.com>

On 2023/11/24 16:51, Ping-Ke Shih wrote:
> 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.

Hi,  Ping-Ke

Replace _rtl8821ae_phy_calculate_bit_shift() by __ffs(bitmask) is better,
but I'm not sure what callers should do when callers check bitmask is 0 before calling.
Maybe this check is useless?

I can send a v3 patch if using  __ffs(bitmask) and no check for bitmask is fine.
Or could you send this patch if you have a better idea?
Thanks for your suggestion!

Su Hui


  reply	other threads:[~2023-11-24 10:06 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
2023-11-24 10:06     ` Su Hui [this message]
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=cb551005-eff0-1391-92a0-d956b3d2b930@nfschina.com \
    --to=suhui@nfschina.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=pkshih@realtek.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

all inboxes | Powered by JetHome®