Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp438963yba; Fri, 3 May 2019 04:54:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6fYB17amtjkWb59PaLUJwiCWOA56/uyPslMJi0VCtMf/+HAp56JVjQ7kunOY/TDHER0zL X-Received: by 2002:a65:5c89:: with SMTP id a9mr9786286pgt.334.1556884450359; Fri, 03 May 2019 04:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556884450; cv=none; d=google.com; s=arc-20160816; b=KDsktfK+KziAjyGAwJRoMG1tGYF5p9sDZhXO2CFXCq4VmfP/RBSLcy9k4NBbBVoLEH 404JRmUA8xKI+XErnCt2f1FjiWhNOKZXMVKI3DCrT19LjxshzqLqM713IXd+hrAqs5Aj wCHXVwAHINuvFAnlKRNQR3C8IOyvA65sk7Zad6BbgfNgD3//NcRWZhMZMC1EjwAnUMCn o+BZOgkX/gJlIYhJ9oa+oD2h6LNl2q+4yNN1PYn9bS0wKXvg3mcd0JlUYWcYdnxRd10r xAf0T6hRJZ9FZVY9GKVw80SWOKb0IhfbmKWRDHm/PG449xvJqaQ5DM0evYOTo+Gnwxkx 1vjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date; bh=KoLConFKFNwcKFki5yU8xNHXmfX61FY00UVh67jOkNk=; b=ILcpmbGVsQMg/tXDPLDe3QxnPg1JpqK8shC/LjUaVJJOWguVtS0h93g58E8OqRpgdg PahSSRGiShnsV7kH3N1/6H/kjEpuNQQp/7yzdgCVhPs6+YueGDiV4/vBb1YFAmdsgd6t qu3+YWqrzRjbjOOCl4JFJlmVm1fGiSLLIsge2knTih8IY0Wx4M2k9RtkXh8uQtT5ijs5 7TpdbH+YEKFqHLKykHYOfOVjR0EQnaiWEVgOsL6Kaq131cfkajWxWujCS14j5FLCK7sW k45vZp5L4rml+oJvnJqlsxID/MxcJpDp0A0h+8kOs1qDhg0tG0eMQM2I6ChXQsUW1jFk Ay5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i125si1980357pfb.126.2019.05.03.04.53.46; Fri, 03 May 2019 04:54:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbfECLxg (ORCPT + 99 others); Fri, 3 May 2019 07:53:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48116 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbfECLxg (ORCPT ); Fri, 3 May 2019 07:53:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DC3D5277B; Fri, 3 May 2019 11:53:36 +0000 (UTC) Received: from localhost (unknown [10.43.2.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC7CC5C6AA; Fri, 3 May 2019 11:53:35 +0000 (UTC) Date: Fri, 3 May 2019 13:53:33 +0200 From: Stanislaw Gruszka To: Tony Chuang Cc: linux-wireless@vger.kernel.org Subject: [RFC] rtw88: fix subscript above array bounds compiler warning Message-ID: <20190503115333.GA23109@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 03 May 2019 11:53:36 +0000 (UTC) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- 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