From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH 2/8] conf: Drop duplicate, diverging optstring assignments Date: Fri, 07 Oct 2022 17:20:34 +1100 Message-ID: In-Reply-To: <20221007004742.1188933-3-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4647133418234208210==" --===============4647133418234208210== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Fri, Oct 07, 2022 at 02:47:36AM +0200, Stefano Brivio wrote: > 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) { -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --===============4647133418234208210== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1NL3hTd0FDZ2tRZ3lwWTRnRXcKWVNLWjR4QUF1dWI5cUVzMmxH bUpmOVF6TVhnZUZCNUpSem1FaTlQQnBLNmpaU2NXTDlUWHZhcGlvT3Q4OGxURwpQdmkxRjQrRTFt SjdNakdiaFJXQ1A4NG9UWEowR1gwQlNaNG5UNEhUM0o0NEF3a0tuQzNxV0ZIaHBYUlZTeFc2CkFx b2NCVGcybjVGdVViem10MS8rUWRlOEZOSkVJaEsycTRUbWhySmxTbEVBaTNlN3FtSVBER3BGNGhF SUFJcm8KRW5COFJTNDdGL0E3Rlh5WmN4dWhFSEhXVCtCYTBMN0lNVkF4ZTdzUndXTzhWNng1NTNo R1hNV0NUMGhjdUtLSQpLQ2lxTUd0TjlBcFVydm56R2ZzTHBBWlVqUkpkNlEwNmRDclZ3Y1p0N3pj Zmw2d0hwU0VESVhqcmZraEpsb0s5CkY2dXU0bk56QTU0UTNKdllOcnd0MEMzemNHQnZTbWM4bFR5 YTcxSzhkSEdKMGFo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