From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id C75545A026C; Mon, 10 Oct 2022 10:35:48 +0200 (CEST) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH v3 2/7] conf: Drop duplicate, diverging optstring assignments Date: Mon, 10 Oct 2022 10:35:43 +0200 Message-Id: <20221010083548.831309-3-sbrivio@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221010083548.831309-1-sbrivio@redhat.com> References: <20221010083548.831309-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: EWVR4MP3K2BA3F6GLYMK7EBPN2WZBJBC X-Message-ID-Hash: EWVR4MP3K2BA3F6GLYMK7EBPN2WZBJBC X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This originated as a result of copy and paste to introduce a second stage for processing options related to port forwarding, has already bitten David in the past, and just gave me hours of fun. As a matter of fact, the second set of optstring assignments was already incorrect, but it didn't matter because the first one was more restrictive, not allowing optional arguments for -P, -D, -S. Signed-off-by: Stefano Brivio Reviewed-by: David Gibson --- conf.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/conf.c b/conf.c index ba1d8de..e9cd4a7 100644 --- a/conf.c +++ b/conf.c @@ -1043,25 +1043,23 @@ void conf(struct ctx *c, int argc, char **argv) struct fqdn *dnss = c->dns_search; uint32_t *dns4 = c->ip4.dns; int name, ret, mask, b, i; + const char *optstring; unsigned int ifi = 0; char *runas = NULL; uid_t uid; gid_t gid; - if (c->mode == MODE_PASTA) + if (c->mode == MODE_PASTA) { c->no_dhcp_dns = c->no_dhcp_dns_search = 1; + optstring = "dqfehI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:"; + } else { + optstring = "dqfehs:p:P:m:a:n:M:g:i:D:S:46t:u:"; + } c->tcp.fwd_in.mode = c->tcp.fwd_out.mode = 0; c->udp.fwd_in.f.mode = c->udp.fwd_out.f.mode = 0; do { - const char *optstring; - - if (c->mode == MODE_PASST) - optstring = "dqfehs:p:P:m:a:n:M:g:i:D:S:46t:u:"; - else - optstring = "dqfehI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:"; - name = getopt_long(argc, argv, optstring, options, NULL); switch (name) { @@ -1505,12 +1503,6 @@ void conf(struct ctx *c, int argc, char **argv) optind = 1; do { struct port_fwd *fwd = NULL; - const char *optstring; - - if (c->mode == MODE_PASST) - optstring = "dqfehs:p::P:m:a:n:M:g:i:D::S::46t:u:"; - else - optstring = "dqfehI:p::P:m:a:n:M:g:i:D::S::46t:u:T:U:"; name = getopt_long(argc, argv, optstring, options, NULL); switch (name) { -- 2.35.1