From: Ping-Ke Shih <pkshih@realtek.com>
To: lilinmao <lilinmao@kylinos.cn>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "kvalo@kernel.org" <kvalo@kernel.org>
Subject: RE: [PATCH] wifi: rtw89: 8852b: fix cppcheck issues
Date: Mon, 8 Jan 2024 01:49:07 +0000 [thread overview]
Message-ID: <fa53ebc977c9494496c16e311f5a3ad2@realtek.com> (raw)
In-Reply-To: <20240105104542.463834-1-lilinmao@kylinos.cn>
> -----Original Message-----
> From: lilinmao <lilinmao@kylinos.cn>
> Sent: Friday, January 5, 2024 6:46 PM
> To: linux-wireless@vger.kernel.org
> Cc: Ping-Ke Shih <pkshih@realtek.com>; kvalo@kernel.org; lilinmao <lilinmao@kylinos.cn>
> Subject: [PATCH] wifi: rtw89: 8852b: fix cppcheck issues
The subject doesn't address the problem or describe the changes you made.
Maybe, you can say "fix out of bounds of iqk_mcc_ch[][] array", but actually
cppcheck reported a false alarm, doesn't it?
[...]
> Signed-off-by: lilinmao <lilinmao@kylinos.cn>
You should give your real name here as well as "From:" field.
> ---
> drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
> b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
> index 259df67836a0..03dec3f4e7ba 100644
> --- a/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
> +++ b/drivers/net/wireless/realtek/rtw89/rtw8852b_rfk.c
> @@ -1388,17 +1388,15 @@ static void _iqk_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, u
> u32 reg_rf18;
> u32 reg_35c;
> u8 idx;
> - u8 get_empty_table = false;
>
> for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++) {
> if (iqk_info->iqk_mcc_ch[idx][path] == 0) {
> - get_empty_table = true;
> break;
> }
> }
> rtw89_debug(rtwdev, RTW89_DBG_RFK, "[IQK] (1)idx = %x\n", idx);
>
> - if (!get_empty_table) {
> + if (idx > RTW89_IQK_CHS_NR - 1) {
> idx = iqk_info->iqk_table_idx[path] + 1;
> if (idx > 1)
> idx = 0;
The original logic looks like
bool found = false;
for (idx = 0; idx < RTW89_IQK_CHS_NR; idx++)
if (expr) {
found = true;
break;
}
if (!found) {
... [A]
}
So, idx >= RTW89_IQK_CHS_NR must fall into branch [A]. Can you report this
pattern to cppcheck?
Ping-Ke
next prev parent reply other threads:[~2024-01-08 1:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 10:45 [PATCH] wifi: rtw89: 8852b: fix cppcheck issues lilinmao
2024-01-05 10:50 ` Johannes Berg
2024-01-08 1:49 ` Ping-Ke Shih [this message]
[not found] ` <1704693852309064.667.seg@mailgw>
[not found] ` <077A3848-0696-4DCC-99C3-DB5389EA2EA2@kylinos.cn>
2024-01-08 15:23 ` Kalle Valo
2024-01-09 4:48 ` Ping-Ke Shih
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=fa53ebc977c9494496c16e311f5a3ad2@realtek.com \
--to=pkshih@realtek.com \
--cc=kvalo@kernel.org \
--cc=lilinmao@kylinos.cn \
--cc=linux-wireless@vger.kernel.org \
/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