From patchwork Sun Oct 1 19:30:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=A9r=C3=A9my_Lefaure?= X-Patchwork-Id: 9979861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A53AE602A0 for ; Sun, 1 Oct 2017 19:41:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C4641FEBA for ; Sun, 1 Oct 2017 19:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9120128AAF; Sun, 1 Oct 2017 19:41:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56AA61FEBA for ; Sun, 1 Oct 2017 19:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751831AbdJATlR (ORCPT ); Sun, 1 Oct 2017 15:41:17 -0400 Received: from blatinox.fr ([51.254.120.209]:33871 "EHLO vps202351.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604AbdJATlP (ORCPT ); Sun, 1 Oct 2017 15:41:15 -0400 X-Greylist: delayed 594 seconds by postgrey-1.27 at vger.kernel.org; Sun, 01 Oct 2017 15:41:14 EDT Received: from blatinox-laptop.localdomain (modemcable003.167-22-96.mc.videotron.ca [96.22.167.3]) by vps202351.ovh.net (Postfix) with ESMTPA id 552A51CA6D; Sun, 1 Oct 2017 21:31:13 +0200 (CEST) From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= To: Anil Gurumurthy , Sudarsana Kalluru , "James E.J. Bottomley" , "Martin K. Petersen" Cc: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/18] scsi: bfa: use ARRAY_SIZE Date: Sun, 1 Oct 2017 15:30:45 -0400 Message-Id: <20171001193101.8898-8-jeremy.lefaure@lse.epita.fr> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr> References: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using the ARRAY_SIZE macro improves the readability of the code. Found with Coccinelle with the following semantic patch: @r depends on (org || report)@ type T; T[] E; position p; @@ ( (sizeof(E)@p /sizeof(*E)) | (sizeof(E)@p /sizeof(E[...])) | (sizeof(E)@p /sizeof(T)) ) Signed-off-by: Jérémy Lefaure --- drivers/scsi/bfa/bfa_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c index 3e1caec82554..4a03cd9fa63f 100644 --- a/drivers/scsi/bfa/bfa_core.c +++ b/drivers/scsi/bfa/bfa_core.c @@ -16,6 +16,7 @@ * General Public License for more details. */ +#include #include "bfad_drv.h" #include "bfa_modules.h" #include "bfi_reg.h" @@ -1957,7 +1958,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids) {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC}, }; - *npciids = sizeof(__pciids) / sizeof(__pciids[0]); + *npciids = ARRAY_SIZE(__pciids); *pciids = __pciids; }