From: "Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>
To: Anil Gurumurthy <anil.gurumurthy@qlogic.com>,
Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>,
"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>,
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 [thread overview]
Message-ID: <20171001193101.8898-8-jeremy.lefaure@lse.epita.fr> (raw)
In-Reply-To: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr>
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 <jeremy.lefaure@lse.epita.fr>
---
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 <linux/kernel.h>
#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;
}
--
2.14.1
next prev parent reply other threads:[~2017-10-01 19:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-01 19:30 [PATCH 00/18] use ARRAY_SIZE macro Jérémy Lefaure
2017-10-01 19:30 ` Jérémy Lefaure [this message]
2017-10-01 22:01 ` Tobin C. Harding
2017-10-02 0:52 ` Jérémy Lefaure
2017-10-02 5:35 ` Greg KH
2017-10-02 19:22 ` J. Bruce Fields
2017-10-03 1:33 ` Jérémy Lefaure
2017-10-05 17:57 ` J. Bruce Fields
2017-10-02 16:37 ` Mauro Carvalho Chehab
2017-10-02 17:05 ` Zhi Wang
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=20171001193101.8898-8-jeremy.lefaure@lse.epita.fr \
--to=jeremy.lefaure@lse.epita.fr \
--cc=anil.gurumurthy@qlogic.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sudarsana.kalluru@qlogic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).