Skip to contentSkip to conversation

trivial: use ARRAY_SIZE

PATCH Applied Kulikov Vasiliy 2 participants 2 messages Jun 28, 2010 – Jul 20, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 7/16 trivial: use ARRAY_SIZE

Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).

---
 drivers/scsi/bfa/bfa_fcs.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/bfa/bfa_fcs.c +4 -6
index 3516172..153cb2a 100644
@@ -86,7 +86,7 @@ bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
 	bfa_attach_fcs(bfa);
 	fcbuild_init();
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->attach)
 			mod->attach(fcs);
@@ -102,7 +102,7 @@ bfa_fcs_init(struct bfa_fcs_s *fcs)
 	int             i;
 	struct bfa_fcs_mod_s  *mod;
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->modinit)
 			mod->modinit(fcs);
@@ -163,13 +163,11 @@ void
 bfa_fcs_exit(struct bfa_fcs_s *fcs)
 {
 	struct bfa_fcs_mod_s  *mod;
-	int             nmods, i;
+	int i;
 
 	bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
 
-	nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]);
-
-	for (i = 0; i < nmods; i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 
 		mod = &fcs_modules[i];
 		if (mod->modexit) {
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 35 lines · Kulikov Vasiliy

Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).

---
 drivers/scsi/bfa/bfa_fcs.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/scsi/bfa/bfa_fcs.c +3 -3
index 3516172..153cb2a 100644
@@ -86,7 +86,7 @@ bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
 	bfa_attach_fcs(bfa);
 	fcbuild_init();
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->attach)
 			mod->attach(fcs);
@@ -102,7 +102,7 @@ bfa_fcs_init(struct bfa_fcs_s *fcs)
 	int             i;
 	struct bfa_fcs_mod_s  *mod;
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->modinit)
 			mod->modinit(fcs);
@@ -163,13 +163,11 @@ void
 bfa_fcs_exit(struct bfa_fcs_s *fcs)
 {
 	struct bfa_fcs_mod_s  *mod;
-	int             nmods, i;
+	int i;

drivers/scsi/bfa/bfa_fcs.c void · line 173

Quoted 10 lines
drivers/scsi/bfa/bfa_fcs.c +1 -3
 
 	bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
 
-	nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]);
-
-	for (i = 0; i < nmods; i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 
 		mod = &fcs_modules[i];
 		if (mod->modexit) {

I have folded this patch into the other bfa change you made, and applied. Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.