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_REJECT.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'extensions/libip6t_REJECT.c') diff --git a/extensions/libip6t_REJECT.c b/extensions/libip6t_REJECT.c index 527f5950..9ad3b685 100644 --- a/extensions/libip6t_REJECT.c +++ b/extensions/libip6t_REJECT.c @@ -43,7 +43,7 @@ print_reject_types(void) printf("Valid reject types:\n"); - for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) { + for (i = 0; i < ARRAY_SIZE(reject_table); ++i) { printf(" %-25s\t%s\n", reject_table[i].name, reject_table[i].desc); printf(" %-25s\talias\n", reject_table[i].alias); } @@ -79,7 +79,6 @@ static int REJECT_parse(int c, char **argv, int invert, unsigned int *flags, { struct ip6t_reject_info *reject = (struct ip6t_reject_info *)(*target)->data; - unsigned int limit = sizeof(reject_table)/sizeof(struct reject_names); unsigned int i; switch(c) { @@ -87,13 +86,12 @@ static int REJECT_parse(int c, char **argv, int invert, unsigned int *flags, if (xtables_check_inverse(optarg, &invert, NULL, 0)) xtables_error(PARAMETER_PROBLEM, "Unexpected `!' after --reject-with"); - for (i = 0; i < limit; i++) { + for (i = 0; i < ARRAY_SIZE(reject_table); ++i) if ((strncasecmp(reject_table[i].name, optarg, strlen(optarg)) == 0) || (strncasecmp(reject_table[i].alias, optarg, strlen(optarg)) == 0)) { reject->with = reject_table[i].with; return 1; } - } xtables_error(PARAMETER_PROBLEM, "unknown reject type \"%s\"", optarg); default: /* Fall through */ @@ -109,10 +107,9 @@ static void REJECT_print(const void *ip, const struct xt_entry_target *target, = (const struct ip6t_reject_info *)target->data; unsigned int i; - for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) { + for (i = 0; i < ARRAY_SIZE(reject_table); ++i) if (reject_table[i].with == reject->with) break; - } printf("reject-with %s ", reject_table[i].name); } @@ -122,7 +119,7 @@ static void REJECT_save(const void *ip, const struct xt_entry_target *target) = (const struct ip6t_reject_info *)target->data; unsigned int i; - for (i = 0; i < sizeof(reject_table)/sizeof(struct reject_names); i++) + for (i = 0; i < ARRAY_SIZE(reject_table); ++i) if (reject_table[i].with == reject->with) break; -- cgit v1.2.3