158b941
From 37164fe78406e201302ec8bd975698bec48183b9 Mon Sep 17 00:00:00 2001
158b941
From: Michael Buesch <mb@bu3sch.de>
158b941
Date: Fri, 21 Aug 2009 15:59:08 +0200
158b941
Subject: [PATCH 3/3] fwcutter: Use ARRAY_SIZE
158b941
158b941
Signed-off-by: Michael Buesch <mb@bu3sch.de>
158b941
---
158b941
 fwcutter/fwcutter.c      |    6 +++---
158b941
 fwcutter/fwcutter.h      |    3 +++
158b941
 fwcutter/fwcutter_list.h |    8 ++++----
158b941
 3 files changed, 10 insertions(+), 7 deletions(-)
158b941
158b941
diff --git a/fwcutter/fwcutter.c b/fwcutter/fwcutter.c
158b941
index 5d5aa80..0d82806 100644
158b941
--- a/fwcutter/fwcutter.c
158b941
+++ b/fwcutter/fwcutter.c
158b941
@@ -462,10 +462,10 @@ static void print_supported_files(void)
158b941
 	       "<ID>\t"
158b941
 	       "<MD5 checksum>\n\n");
158b941
 	/* print for legacy driver first */
158b941
-	for (i = 0; i < FILES; i++)
158b941
+	for (i = 0; i < ARRAY_SIZE(files); i++)
158b941
 		if (file_ok(&files[i]) && !(files[i].flags & FW_FLAG_V4))
158b941
 			print_file(&files[i]);
158b941
-	for (i = 0; i < FILES; i++)
158b941
+	for (i = 0; i < ARRAY_SIZE(files); i++)
158b941
 		if (file_ok(&files[i]) && files[i].flags & FW_FLAG_V4)
158b941
 			print_file(&files[i]);
158b941
 	printf("\n");
158b941
@@ -491,7 +491,7 @@ static const struct file *find_file(FILE *fd)
158b941
 		 signature[8], signature[9], signature[10], signature[11],
158b941
 		 signature[12], signature[13], signature[14], signature[15]);
158b941
 
158b941
-	for (i = 0; i < FILES; ++i) {
158b941
+	for (i = 0; i < ARRAY_SIZE(files); i++) {
158b941
 		if (file_ok(&files[i]) &&
158b941
 		    strcasecmp(md5sig, files[i].md5) == 0) {
158b941
 			printf("This file is recognised as:\n");
158b941
diff --git a/fwcutter/fwcutter.h b/fwcutter/fwcutter.h
158b941
index ac2df63..4a887b6 100644
158b941
--- a/fwcutter/fwcutter.h
158b941
+++ b/fwcutter/fwcutter.h
158b941
@@ -9,6 +9,9 @@
158b941
 #define fwcutter_stringify(x)	fwcutter_stringify_1(x)
158b941
 #define FWCUTTER_VERSION	fwcutter_stringify(FWCUTTER_VERSION_)
158b941
 
158b941
+#undef ARRAY_SIZE
158b941
+#define ARRAY_SIZE(array)	(sizeof(array) / sizeof((array)[0]))
158b941
+
158b941
 typedef uint16_t be16_t; /* Big-endian 16bit */
158b941
 typedef uint32_t be32_t; /* Big-endian 32bit */
158b941
 
158b941
diff --git a/fwcutter/fwcutter_list.h b/fwcutter/fwcutter_list.h
158b941
index 65c8671..5175bbd 100644
158b941
--- a/fwcutter/fwcutter_list.h
158b941
+++ b/fwcutter/fwcutter_list.h
158b941
@@ -287,6 +287,7 @@ static struct extract _1a258b2d93efa641c32ddf3c3a962028[] =
158b941
 	{ .name = "sslpn0bsinitvals16", .offset = 0xAF048, .type = EXT_IV, .length = 0x0 },
158b941
 	EXTRACT_LIST_END
158b941
 };
158b941
+
158b941
 static struct extract _bb8537e3204a1ea5903fe3e66b5e2763[] =
158b941
 {
158b941
 	/* ucode major version at offset 0xa8b70 */
158b941
@@ -337,7 +338,9 @@ static struct extract _bb8537e3204a1ea5903fe3e66b5e2763[] =
158b941
 	{ .name = "sslpn0bsinitvals16", .offset = 0xB5348, .type = EXT_IV, .length = 0x0 },
158b941
 	{ .name = "lp0bsinitvals16", .offset = 0xB5FE8, .type = EXT_IV, .length = 0x118 },
158b941
 	EXTRACT_LIST_END
158b941
-};/*
158b941
+};
158b941
+
158b941
+/*
158b941
  * Links change, so let's not put them into the README.
158b941
  * I still put them here so we know where the file was obtained.
158b941
  */
158b941
@@ -417,6 +420,3 @@ static const struct file files[] =
158b941
 		.extract	= _bb8537e3204a1ea5903fe3e66b5e2763,
158b941
 	},
158b941
 };
158b941
-
158b941
-#define FILES (sizeof(files) / sizeof(files[0]))
158b941
-
158b941
-- 
158b941
1.6.4
158b941