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/libip6t_ipv6header.c | |
parent | 69f564e3890976461de0016cd81171ff8bfa8353 (diff) |
iptables: replace open-coded sizeof by ARRAY_SIZE
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'extensions/libip6t_ipv6header.c')
-rw-r--r-- | extensions/libip6t_ipv6header.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/extensions/libip6t_ipv6header.c b/extensions/libip6t_ipv6header.c index 479b3132..2674c8fb 100644 --- a/extensions/libip6t_ipv6header.c +++ b/extensions/libip6t_ipv6header.c @@ -77,7 +77,7 @@ proto_to_name(u_int8_t proto, int nolookup) return pent->p_name; } - for (i = 0; i < sizeof(chain_protos)/sizeof(struct pprot); i++) + for (i = 0; i < ARRAY_SIZE(chain_protos); ++i) if (chain_protos[i].num == proto) return chain_protos[i].name; @@ -94,16 +94,13 @@ name_to_proto(const char *s) proto = pent->p_proto; else { unsigned int i; - for (i = 0; - i < sizeof(chain_protos)/sizeof(struct pprot); - i++) { + for (i = 0; i < ARRAY_SIZE(chain_protos); ++i) if (strcmp(s, chain_protos[i].name) == 0) { proto = chain_protos[i].num; break; } - } - if (i == sizeof(chain_protos)/sizeof(struct pprot)) + if (i == ARRAY_SIZE(chain_protos)) xtables_error(PARAMETER_PROBLEM, "unknown header `%s' specified", s); @@ -116,16 +113,13 @@ static unsigned int add_proto_to_mask(int proto){ unsigned int i=0, flag=0; - for (i = 0; - i < sizeof(chain_flags)/sizeof(struct numflag); - i++) { + for (i = 0; i < ARRAY_SIZE(chain_flags); ++i) if (proto == chain_flags[i].proto){ flag = chain_flags[i].flag; break; } - } - if (i == sizeof(chain_flags)/sizeof(struct numflag)) + if (i == ARRAY_SIZE(chain_flags)) xtables_error(PARAMETER_PROBLEM, "unknown header `%d' specified", proto); |