diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-04-30 19:32:02 +0200 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2009-05-26 13:14:15 +0200 |
commit | 2c69b55e55f2efc5a334b87ccdceaa9de0ecb658 (patch) | |
tree | f68c86d49be428f2e46f483eec0b36d01a15e311 /extensions/libipt_icmp.c | |
parent | 69f564e3890976461de0016cd81171ff8bfa8353 (diff) |
iptables: replace open-coded sizeof by ARRAY_SIZE
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'extensions/libipt_icmp.c')
-rw-r--r-- | extensions/libipt_icmp.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/extensions/libipt_icmp.c b/extensions/libipt_icmp.c index 15c17872..56679552 100644 --- a/extensions/libipt_icmp.c +++ b/extensions/libipt_icmp.c @@ -83,7 +83,7 @@ print_icmptypes(void) unsigned int i; printf("Valid ICMP Types:"); - for (i = 0; i < sizeof(icmp_codes)/sizeof(struct icmp_names); i++) { + for (i = 0; i < ARRAY_SIZE(icmp_codes); ++i) { if (i && icmp_codes[i].type == icmp_codes[i-1].type) { if (icmp_codes[i].code_min == icmp_codes[i-1].code_min && (icmp_codes[i].code_max @@ -115,7 +115,7 @@ static const struct option icmp_opts[] = { static void parse_icmp(const char *icmptype, u_int8_t *type, u_int8_t code[]) { - unsigned int limit = sizeof(icmp_codes)/sizeof(struct icmp_names); + static const unsigned int limit = ARRAY_SIZE(icmp_codes); unsigned int match = limit; unsigned int i; @@ -206,16 +206,13 @@ static void print_icmptype(u_int8_t type, if (!numeric) { unsigned int i; - for (i = 0; - i < sizeof(icmp_codes)/sizeof(struct icmp_names); - i++) { + for (i = 0; i < ARRAY_SIZE(icmp_codes); ++i) if (icmp_codes[i].type == type && icmp_codes[i].code_min == code_min && icmp_codes[i].code_max == code_max) break; - } - if (i != sizeof(icmp_codes)/sizeof(struct icmp_names)) { + if (i != ARRAY_SIZE(icmp_codes)) { printf("%s%s ", invert ? "!" : "", icmp_codes[i].name); |