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/libxt_pkttype.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'extensions/libxt_pkttype.c') diff --git a/extensions/libxt_pkttype.c b/extensions/libxt_pkttype.c index 50af3ed4..e3db2aa9 100644 --- a/extensions/libxt_pkttype.c +++ b/extensions/libxt_pkttype.c @@ -46,11 +46,9 @@ static void print_types(void) unsigned int i; printf("Valid packet types:\n"); - for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++) - { + for (i = 0; i < ARRAY_SIZE(supported_types); ++i) if(supported_types[i].printhelp == 1) printf("\t%-14s\t\t%s\n", supported_types[i].name, supported_types[i].help); - } printf("\n"); } @@ -71,14 +69,12 @@ static void parse_pkttype(const char *pkttype, struct xt_pkttype_info *info) { unsigned int i; - for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++) - { + for (i = 0; i < ARRAY_SIZE(supported_types); ++i) if(strcasecmp(pkttype, supported_types[i].name)==0) { info->pkttype=supported_types[i].pkttype; return; } - } xtables_error(PARAMETER_PROBLEM, "Bad packet type '%s'", pkttype); } @@ -115,14 +111,12 @@ static void print_pkttype(const struct xt_pkttype_info *info) { unsigned int i; - for (i = 0; i < sizeof(supported_types)/sizeof(struct pkttypes); i++) - { + for (i = 0; i < ARRAY_SIZE(supported_types); ++i) if(supported_types[i].pkttype==info->pkttype) { printf("%s ", supported_types[i].name); return; } - } printf("%d ", info->pkttype); /* in case we didn't find an entry in named-packtes */ } -- cgit v1.2.3