diff options
author | Jean Delvare <jdelvare@suse.de> | 2007-02-11 20:10:59 +0000 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2007-02-11 20:10:59 +0000 |
commit | 850f5935dd4d354c80a8f03f0e215aaaab5d1773 (patch) | |
tree | f907abb8e63d79e6301e734e088ed078b5947a4e | |
parent | 3e7a3c2ab90404f3849553b6d9ac7c6569ece7fb (diff) | |
download | dmidecode-git-850f5935dd4d354c80a8f03f0e215aaaab5d1773.tar.gz |
Define an ARRAY_SIZE macro which computes the size of a static array, and
use it where relevant.
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | dmiopt.c | 9 | ||||
-rw-r--r-- | util.h | 2 | ||||
-rw-r--r-- | vpdopt.c | 5 |
4 files changed, 12 insertions, 8 deletions
@@ -60,7 +60,7 @@ dmidecode.o : dmidecode.c version.h types.h util.h config.h dmidecode.h \ dmiopt.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ -dmiopt.o : dmiopt.c config.h types.h dmidecode.h dmiopt.h +dmiopt.o : dmiopt.c config.h types.h util.h dmidecode.h dmiopt.h $(CC) $(CFLAGS) -c $< -o $@ dmioem.o : dmioem.c types.h dmidecode.h dmioem.h @@ -75,7 +75,7 @@ ownership.o : ownership.c version.h types.h util.h config.h vpddecode.o : vpddecode.c version.h types.h util.h config.h vpdopt.h $(CC) $(CFLAGS) -c $< -o $@ -vpdopt.o : vpdopt.c config.h vpdopt.h +vpdopt.o : vpdopt.c config.h util.h vpdopt.h $(CC) $(CFLAGS) -c $< -o $@ util.o : util.c types.h util.h config.h @@ -26,6 +26,7 @@ #include "config.h" #include "types.h" +#include "util.h" #include "dmidecode.h" #include "dmiopt.h" @@ -71,7 +72,7 @@ static void print_opt_type_list(void) unsigned int i; fprintf(stderr, "Valid type keywords are:\n"); - for(i=0; i<sizeof(opt_type_keyword)/sizeof(struct type_keyword); i++) + for(i=0; i<ARRAY_SIZE(opt_type_keyword); i++) { fprintf(stderr, " %s\n", opt_type_keyword[i].keyword); } @@ -93,7 +94,7 @@ static u8 *parse_opt_type(u8 *p, const char *arg) } /* First try as a keyword */ - for(i=0; i<sizeof(opt_type_keyword)/sizeof(struct type_keyword); i++) + for(i=0; i<ARRAY_SIZE(opt_type_keyword); i++) { if(!strcasecmp(arg, opt_type_keyword[i].keyword)) { @@ -175,7 +176,7 @@ static void print_opt_string_list(void) unsigned int i; fprintf(stderr, "Valid string keywords are:\n"); - for(i=0; i<sizeof(opt_string_keyword)/sizeof(struct string_keyword); i++) + for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++) { fprintf(stderr, " %s\n", opt_string_keyword[i].keyword); } @@ -191,7 +192,7 @@ static int parse_opt_string(const char *arg) return -1; } - for(i=0; i<sizeof(opt_string_keyword)/sizeof(struct string_keyword); i++) + for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++) { if(!strcasecmp(arg, opt_string_keyword[i].keyword)) { @@ -2,5 +2,7 @@ #include "types.h" +#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) + int checksum(const u8 *buf, size_t len); void *mem_chunk(size_t base, size_t len, const char *devmem); @@ -25,6 +25,7 @@ #include <getopt.h> #include "config.h" +#include "util.h" #include "vpdopt.h" @@ -52,7 +53,7 @@ static void print_opt_string_list(void) unsigned int i; fprintf(stderr, "Valid string keywords are:\n"); - for(i=0; i<sizeof(opt_string_keyword)/sizeof(struct string_keyword); i++) + for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++) { fprintf(stderr, " %s\n", opt_string_keyword[i].keyword); } @@ -68,7 +69,7 @@ static int parse_opt_string(const char *arg) return -1; } - for(i=0; i<sizeof(opt_string_keyword)/sizeof(struct string_keyword); i++) + for(i=0; i<ARRAY_SIZE(opt_string_keyword); i++) { if(!strcasecmp(arg, opt_string_keyword[i].keyword)) { |