From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Tony Chuang <yhchuang@realtek.com>
Cc: linux-wireless@vger.kernel.org
Subject: [RFC] rtw88: fix subscript above array bounds compiler warning
Date: Fri, 3 May 2019 13:53:33 +0200 [thread overview]
Message-ID: <20190503115333.GA23109@redhat.com> (raw)
My compiler complain about:
drivers/net/wireless/realtek/rtw88/phy.c: In function ‘rtw_phy_rf_power_2_rssi’:
drivers/net/wireless/realtek/rtw88/phy.c:430:26: warning: array subscript is above array bounds [-Warray-bounds]
linear = db_invert_table[i][j];
According to comment power_db should be in range 1 ~ 96 .
Correct rtw_phy_power_2_db() to make max power 96 db
(still min is 0). This make the warning gone.
However power >= 20 check still looks somewhat suspicious to me.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/net/wireless/realtek/rtw88/phy.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c
index 35a35dbca85f..a716a44d78b0 100644
--- a/drivers/net/wireless/realtek/rtw88/phy.c
+++ b/drivers/net/wireless/realtek/rtw88/phy.c
@@ -410,12 +410,12 @@ void rtw_phy_dynamic_mechanism(struct rtw_dev *rtwdev)
static u8 rtw_phy_power_2_db(s8 power)
{
- if (power <= -100 || power >= 20)
+ if (power <= -96 || power >= 20)
return 0;
else if (power >= 0)
- return 100;
+ return 96;
else
- return 100 + power;
+ return 96 + power;
}
static u64 rtw_phy_db_2_linear(u8 power_db)
--
1.9.3
next reply other threads:[~2019-05-03 11:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-03 11:53 Stanislaw Gruszka [this message]
2019-05-03 12:01 ` [RFC] rtw88: fix subscript above array bounds compiler warning Tony Chuang
2019-05-03 12:24 ` Stanislaw Gruszka
2019-05-06 3:42 ` Tony Chuang
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=20190503115333.GA23109@redhat.com \
--to=sgruszka@redhat.com \
--cc=linux-wireless@vger.kernel.org \
--cc=yhchuang@realtek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.