From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id F12115A0272 for ; Wed, 8 Mar 2023 23:45:12 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PX6pF68cNz4xDv; Thu, 9 Mar 2023 09:45:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1678315509; bh=v6kGBdDJ4rBsDxIic0XAiG3kkrC+pvjMpZZ9A5GjdnA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BZVa1cGpkY31e6v3OUkxdRlJEPOfXleHYJoiHJTVfm0CCUsE0shY8S7+APRtyeKNa uURQgMBwhizfVTS/LHZF/C4JkgH7yCNtnUsqW9g4l0nDLz2hH+9kIJxJerau0KUBqN SYQ+/cdV4hMegkVhYRFZfMqjejJp7d7Oc6ZgYM/8= Date: Thu, 9 Mar 2023 09:10:00 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/4] conf, passt: Rename stderr to force_stderr Message-ID: References: <20230308073516.2189680-1-sbrivio@redhat.com> <20230308073516.2189680-3-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5JIyg5Mi9vKCZKoD" Content-Disposition: inline In-Reply-To: <20230308073516.2189680-3-sbrivio@redhat.com> Message-ID-Hash: 7KPM4ATNWOYQI3VCHNX2AB6ZFNQO2IO3 X-Message-ID-Hash: 7KPM4ATNWOYQI3VCHNX2AB6ZFNQO2IO3 X-MailFrom: dgibson@gandalf.ozlabs.org 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: passt-dev@passt.top, Chris Kuhn , lemmi X-Mailman-Version: 3.3.8 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: --5JIyg5Mi9vKCZKoD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 08, 2023 at 08:35:14AM +0100, Stefano Brivio wrote: > From: Chris Kuhn >=20 > While building against musl, gcc informs us that 'stderr' is a > protected keyword. This probably comes from a #define stderr (stderr) > in musl's stdio.h, to avoid a clash with extern FILE *const stderr, > but I didn't really track it down. Just rename it to force_stderr, it > makes more sense. >=20 > [sbrivio: Added commit message] > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson Shadowing a libc global is not a great idea. Since it's a field, not a variable we're not *exactly* doing that, but it's close enough that I think this is better regardless of musl constraints. (I once had a particularly wonderful time tracking down a bizarre bug because 'index' ended up resolving to index(3) instead of the local variable I expected it to). > --- > conf.c | 6 +++--- > passt.c | 2 +- > passt.h | 4 ++-- > 3 files changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/conf.c b/conf.c > index 15506ec..07b0b7b 100644 > --- a/conf.c > +++ b/conf.c > @@ -1356,13 +1356,13 @@ void conf(struct ctx *c, int argc, char **argv) > if (logfile) > die("Can't log to both file and stderr"); > =20 > - if (c->stderr) > + if (c->force_stderr) > die("Multiple --stderr options given"); > =20 > - c->stderr =3D 1; > + c->force_stderr =3D 1; > break; > case 'l': > - if (c->stderr) > + if (c->force_stderr) > die("Can't log to both stderr and file"); > =20 > if (logfile) > diff --git a/passt.c b/passt.c > index 5b8146e..f67213a 100644 > --- a/passt.c > +++ b/passt.c > @@ -241,7 +241,7 @@ int main(int argc, char **argv) > conf(&c, argc, argv); > trace_init(c.trace); > =20 > - if (c.stderr || isatty(fileno(stdout))) > + if (c.force_stderr || isatty(fileno(stdout))) > __openlog(log_name, LOG_PERROR, LOG_DAEMON); > =20 > quit_fd =3D pasta_netns_quit_init(&c); > diff --git a/passt.h b/passt.h > index b73f4ff..006d1c1 100644 > --- a/passt.h > +++ b/passt.h > @@ -158,7 +158,7 @@ struct ip6_ctx { > * @trace: Enable tracing (extra debug) mode > * @quiet: Don't print informational messages > * @foreground: Run in foreground, don't log to stderr by default > - * @stderr: Force logging to stderr > + * @force_stderr: Force logging to stderr > * @nofile: Maximum number of open files (ulimit -n) > * @sock_path: Path for UNIX domain socket > * @pcap: Path for packet capture file > @@ -207,7 +207,7 @@ struct ctx { > int trace; > int quiet; > int foreground; > - int stderr; > + int force_stderr; > int nofile; > char sock_path[UNIX_PATH_MAX]; > char pcap[PATH_MAX]; --=20 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 --5JIyg5Mi9vKCZKoD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmQJB7EACgkQzQJF27ox 2GcOvw/+KUzJwMmyNmfb2dJiTCNnSGTjOcmD+aEtta7jA0gF/tYbObxQ0whhDpne GOiPB5t9rlgoYqYGanv/TsGTyN1aAtL0bFGHTfHbvUBU0i7opyI8TZL7A+mj/sMU r9j85CRWUH9P5al+nhKNGuK9S6BadavF2cQPWVd/pr3oyrhEC6mPA9MnhCCrZex1 0Ak4IN7FQ0+ow1m/8m5z4E0zQTqoMmRhNsMUzDO0FrD/tNlffYx4wUDdSQWJKeED bAuZsAM+IiMuVvLKWZdHJ8JfjRmcG2CopcHawbpIlmH75qTr7msMrCw5Y8ihC7h9 u3qYOyJ1UqCY+e8RZgmIQebV465AlMRH/G6mXe8UQFd4OCW55hE1DsU64KOUY9On JMG0DP5Yq/3Q8Y3zoKLKgHmUwHAV/zrBUSVs0KWaigl9k2+oye+8GBfvQjOQghi6 vHJK2IJqyfi66OS/C3WjHX3XOj+rd6/Bc1WLpVhNeue8SFP+IBxVsBmCwzaYDyVh N5ZvfGtKCWpixQGIaduTnab0hxB/UqL/EHLx9TIi2FCBbfdP0gEZoMjIn9H3d8AW e8ZjS2yiYJNm/191901xKa/yXqP4KAODRDa8XVYnD/CZg/kLIED2LjM61nQM4Hrx BOkuQxtjLzKDVIUWvkh+PIO+1zVJqw96kyosyUPnxyAtCw80WqI= =Qa54 -----END PGP SIGNATURE----- --5JIyg5Mi9vKCZKoD--