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