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_REJECT.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_REJECT.c')
-rw-r--r-- | extensions/libip6t_REJECT.c | 11 |
1 files changed, 4 insertions, 7 deletions
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; |