conf: Remove overly cryptic selection of forward table
In a couple of places in conf(), we use a local 'fwd' variable to reference one of our forwarding tables. The value depends on which command line option we're currently looking at, and is initialized rather cryptically from an assignment side-effect within the if condition checking that option. Newer versions of cppcheck complain about this assignment being an always true condition, but in any case it's both clearer and slightly shorter to use separate if branches for the two cases and set the forwarding parameter more directly. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
6471c7d01b
commit
c0efa4e97f
1 changed files with 8 additions and 12 deletions
20
conf.c
20
conf.c
|
@ -1742,14 +1742,12 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||
/* Inbound port options can be parsed now (after IPv4/IPv6 settings) */
|
||||
optind = 1;
|
||||
do {
|
||||
struct port_fwd *fwd;
|
||||
|
||||
name = getopt_long(argc, argv, optstring, options, NULL);
|
||||
|
||||
if ((name == 't' && (fwd = &c->tcp.fwd_in)) ||
|
||||
(name == 'u' && (fwd = &c->udp.fwd_in.f))) {
|
||||
conf_ports(c, name, optarg, fwd);
|
||||
}
|
||||
if (name == 't')
|
||||
conf_ports(c, name, optarg, &c->tcp.fwd_in);
|
||||
else if (name == 'u')
|
||||
conf_ports(c, name, optarg, &c->udp.fwd_in.f);
|
||||
} while (name != -1);
|
||||
|
||||
if (c->mode == MODE_PASTA)
|
||||
|
@ -1777,14 +1775,12 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||
/* ...and outbound port options now that namespaces are set up. */
|
||||
optind = 1;
|
||||
do {
|
||||
struct port_fwd *fwd;
|
||||
|
||||
name = getopt_long(argc, argv, optstring, options, NULL);
|
||||
|
||||
if ((name == 'T' && (fwd = &c->tcp.fwd_out)) ||
|
||||
(name == 'U' && (fwd = &c->udp.fwd_out.f))) {
|
||||
conf_ports(c, name, optarg, fwd);
|
||||
}
|
||||
if (name == 'T')
|
||||
conf_ports(c, name, optarg, &c->tcp.fwd_out);
|
||||
else if (name == 'U')
|
||||
conf_ports(c, name, optarg, &c->udp.fwd_out.f);
|
||||
} while (name != -1);
|
||||
|
||||
if (!c->ifi4)
|
||||
|
|
Loading…
Reference in a new issue