From patchwork Wed Sep 9 08:45:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Xu X-Patchwork-Id: 1360643 X-Patchwork-Delegate: anthony.l.nguyen@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmkLJ59yDz9sTN for ; Thu, 10 Sep 2020 00:05:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 94B25872DB; Wed, 9 Sep 2020 14:05:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QoRMz9gf3E9u; Wed, 9 Sep 2020 14:05:08 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 7E653872D2; Wed, 9 Sep 2020 14:05:08 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 416A61BF5A3 for ; Wed, 9 Sep 2020 08:49:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id EC04C2E150 for ; Wed, 9 Sep 2020 08:49:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j5cMIj37yPx5 for ; Wed, 9 Sep 2020 08:49:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by silver.osuosl.org (Postfix) with ESMTPS id 65E512E13F for ; Wed, 9 Sep 2020 08:49:24 +0000 (UTC) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4A5E4A72608B428739F2; Wed, 9 Sep 2020 16:49:19 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Wed, 9 Sep 2020 16:49:09 +0800 From: Wei Xu To: Date: Wed, 9 Sep 2020 16:45:33 +0800 Message-ID: <1599641134-204167-1-git-send-email-xuwei5@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-Mailman-Approved-At: Wed, 09 Sep 2020 14:05:07 +0000 Subject: [Intel-wired-lan] [net-next] net: i40e: Use the ARRAY_SIZE macro for aq_to_posix X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: salil.mehta@huawei.com, jinying@hisilicon.com, tangkunshan@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, shameerali.kolothum.thodi@huawei.com, zhangyi.ac@huawei.com, intel-wired-lan@lists.osuosl.org, xuwei5@hisilicon.com, jonathan.cameron@huawei.com, Jakub Kicinski , liguozhu@hisilicon.com, davem@davemloft.net, shiju.jose@huawei.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Use the ARRAY_SIZE macro to calculate the size of an array. This code was detected with the help of Coccinelle. Signed-off-by: Wei Xu --- drivers/net/ethernet/intel/i40e/i40e_adminq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h index edec3df..11c5fca 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h +++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h @@ -120,7 +120,7 @@ static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc) if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT) return -EAGAIN; - if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))) + if (!((u32)aq_rc < ARRAY_SIZE(aq_to_posix))) return -ERANGE; return aq_to_posix[aq_rc];