From 2c69b55e55f2efc5a334b87ccdceaa9de0ecb658 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 30 Apr 2009 19:32:02 +0200 Subject: iptables: replace open-coded sizeof by ARRAY_SIZE Signed-off-by: Jan Engelhardt --- extensions/libip6t_ipv6header.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'extensions/libip6t_ipv6header.c') 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); -- cgit v1.2.3