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(a)gibson.dropbear.id.au> --- conf.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/conf.c b/conf.c index 551a9da..a235b31 100644 --- a/conf.c +++ b/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) -- 2.41.0