Actually, if code had followed style(9), there would be less stupid errors

like the one fixed in r223416.

Noticed by:	julian
This commit is contained in:
Gleb Smirnoff 2011-06-24 12:55:16 +00:00
parent 9b9fc082ba
commit 6ca60beb25

View File

@ -738,7 +738,8 @@ ipfw_config_nat(int ac, char **av)
char *id, *buf, **av1, *end;
size_t len;
av++; ac--;
av++;
ac--;
/* Nat id. */
if (ac == 0)
errx(EX_DATAERR, "missing nat id");
@ -746,7 +747,8 @@ ipfw_config_nat(int ac, char **av)
i = (int)strtol(id, &end, 0);
if (i <= 0 || *end != '\0')
errx(EX_DATAERR, "illegal nat id: %s", id);
av++; ac--;
av++;
ac--;
if (ac == 0)
errx(EX_DATAERR, "missing option");
@ -755,11 +757,13 @@ ipfw_config_nat(int ac, char **av)
av1 = av;
while (ac1 > 0) {
tok = match_token(nat_params, *av1);
ac1--; av1++;
ac1--;
av1++;
switch (tok) {
case TOK_IP:
case TOK_IF:
ac1--; av1++;
ac1--;
av1++;
break;
case TOK_ALOG:
case TOK_DENY_INC:
@ -775,18 +779,22 @@ ipfw_config_nat(int ac, char **av)
errx(EX_DATAERR, "redirect_addr: "
"not enough arguments");
len += estimate_redir_addr(&ac1, &av1);
av1 += 2; ac1 -= 2;
av1 += 2;
ac1 -= 2;
break;
case TOK_REDIR_PORT:
if (ac1 < 3)
errx(EX_DATAERR, "redirect_port: "
"not enough arguments");
av1++; ac1--;
av1++;
ac1--;
len += estimate_redir_port(&ac1, &av1);
av1 += 2; ac1 -= 2;
av1 += 2;
ac1 -= 2;
/* Skip optional remoteIP/port */
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
av1++;
ac1--;
}
break;
case TOK_REDIR_PROTO:
@ -794,13 +802,16 @@ ipfw_config_nat(int ac, char **av)
errx(EX_DATAERR, "redirect_proto: "
"not enough arguments");
len += sizeof(struct cfg_redir);
av1 += 2; ac1 -= 2;
av1 += 2;
ac1 -= 2;
/* Skip optional remoteIP/port */
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
av1++;
ac1--;
}
if (ac1 != 0 && isdigit(**av1)) {
av1++; ac1--;
av1++;
ac1--;
}
break;
default:
@ -819,7 +830,8 @@ ipfw_config_nat(int ac, char **av)
while (ac > 0) {
tok = match_token(nat_params, *av);
ac--; av++;
ac--;
av++;
switch (tok) {
case TOK_IP:
if (ac == 0)
@ -827,13 +839,15 @@ ipfw_config_nat(int ac, char **av)
if (!inet_aton(av[0], &(n->ip)))
errx(EX_DATAERR, "bad ip address ``%s''",
av[0]);
ac--; av++;
ac--;
av++;
break;
case TOK_IF:
if (ac == 0)
errx(EX_DATAERR, "missing option");
set_addr_dynamic(av[0], n);
ac--; av++;
ac--;
av++;
break;
case TOK_ALOG:
n->mode |= PKT_ALIAS_LOG;
@ -912,7 +926,8 @@ ipfw_show_nat(int ac, char **av)
data = NULL;
frule = 0;
lrule = IPFW_DEFAULT_RULE; /* max ipfw rule number */
ac--; av++;
ac--;
av++;
if (co.test_only)
return;