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