lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1261265176-5241-1-git-send-email-tfransosi@gmail.com>
Date:	Sat, 19 Dec 2009 18:26:16 -0500
From:	Thiago Farina <tfransosi@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	James.Bottomley@...e.de, robert.w.love@...el.com,
	vasu.dev@...el.com, jeykholt@...co.com, linux-scsi@...r.kernel.org
Subject: [PATCH] scsi/libfc: Clean up hard coded array size calculation.

Use ARRAY_SIZE macro from kernel.h api instead.

Signed-off-by: Thiago Farina <tfransosi@...il.com>
---
 drivers/scsi/libfc/fc_exch.c  |    9 ++++-----
 drivers/scsi/libfc/fc_lport.c |    3 ++-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index c1c1574..b65652a 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -23,9 +23,10 @@
  * Fibre Channel exchange and sequence handling.
  */
 
-#include <linux/timer.h>
-#include <linux/gfp.h>
 #include <linux/err.h>
+#include <linux/gfp.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
 
 #include <scsi/fc/fc_fc2.h>
 
@@ -194,8 +195,6 @@ static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp);
  */
 static char *fc_exch_rctl_names[] = FC_RCTL_NAMES_INIT;
 
-#define FC_TABLE_SIZE(x)   (sizeof(x) / sizeof(x[0]))
-
 static inline const char *fc_exch_name_lookup(unsigned int op, char **table,
 					      unsigned int max_index)
 {
@@ -211,7 +210,7 @@ static inline const char *fc_exch_name_lookup(unsigned int op, char **table,
 static const char *fc_exch_rctl_name(unsigned int op)
 {
 	return fc_exch_name_lookup(op, fc_exch_rctl_names,
-				   FC_TABLE_SIZE(fc_exch_rctl_names));
+				   ARRAY_SIZE(fc_exch_rctl_names));
 }
 
 /*
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index bd2f771..98b4eaf 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -87,6 +87,7 @@
  * (i.e. _enter_* function).
  */
 
+#include <linux/kernel.h>
 #include <linux/timer.h>
 #include <asm/unaligned.h>
 
@@ -1137,7 +1138,7 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport)
 	fc_lport_state_enter(lport, LPORT_ST_RFT_ID);
 
 	lps = &lport->fcts;
-	i = sizeof(lps->ff_type_map) / sizeof(lps->ff_type_map[0]);
+	i = ARRAY_SIZE(lps->ff_type_map);
 	while (--i >= 0)
 		if (ntohl(lps->ff_type_map[i]) != 0)
 			break;
-- 
1.6.6.rc0.61.g41d5b

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ