public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Chris Kuhn <kuhnchris+passt@kuhnchris.eu>,
	lemmi <lemmi@nerd2nerd.org>
Subject: Re: [PATCH 2/4] conf, passt: Rename stderr to force_stderr
Date: Thu, 9 Mar 2023 09:10:00 +1100	[thread overview]
Message-ID: <ZAkHuEsAyZ9ufBMd@yekko> (raw)
In-Reply-To: <20230308073516.2189680-3-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2994 bytes --]

On Wed, Mar 08, 2023 at 08:35:14AM +0100, Stefano Brivio wrote:
> From: Chris Kuhn <kuhnchris+github@kuhnchris.eu>
> 
> 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.
> 
> [sbrivio: Added commit message]
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

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(-)
> 
> 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");
>  
> -			if (c->stderr)
> +			if (c->force_stderr)
>  				die("Multiple --stderr options given");
>  
> -			c->stderr = 1;
> +			c->force_stderr = 1;
>  			break;
>  		case 'l':
> -			if (c->stderr)
> +			if (c->force_stderr)
>  				die("Can't log to both stderr and file");
>  
>  			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);
>  
> -	if (c.stderr || isatty(fileno(stdout)))
> +	if (c.force_stderr || isatty(fileno(stdout)))
>  		__openlog(log_name, LOG_PERROR, LOG_DAEMON);
>  
>  	quit_fd = 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];

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-03-08 22:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08  7:35 [PATCH 0/4] Fix build against musl C library Stefano Brivio
2023-03-08  7:35 ` [PATCH 1/4] netlink: Use 8 KiB * netlink message header size as response buffer Stefano Brivio
2023-03-08 22:06   ` David Gibson
2023-03-08  7:35 ` [PATCH 2/4] conf, passt: Rename stderr to force_stderr Stefano Brivio
2023-03-08 22:10   ` David Gibson [this message]
2023-03-08  7:35 ` [PATCH 3/4] treewide: Fix header includes to build with musl Stefano Brivio
2023-03-08 22:11   ` David Gibson
2023-03-08  7:35 ` [PATCH 4/4] util: Carry own definition of __bswap_constant{16,32} Stefano Brivio
2023-03-08 22:11   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZAkHuEsAyZ9ufBMd@yekko \
    --to=david@gibson.dropbear.id.au \
    --cc=kuhnchris+passt@kuhnchris.eu \
    --cc=lemmi@nerd2nerd.org \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).