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, Yalan Zhang <yalzhang@redhat.com>
Subject: Re: [PATCH v2 6/6] treewide: Replace strerror() calls
Date: Wed, 19 Jun 2024 12:29:06 +1000	[thread overview]
Message-ID: <ZnJCclfxf8KGmyZ6@zatzit> (raw)
In-Reply-To: <20240618071427.1544869-7-sbrivio@redhat.com>

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

On Tue, Jun 18, 2024 at 09:14:27AM +0200, Stefano Brivio wrote:
> Now that we have logging functions embedding perror() functionality,
> we can make _some_ calls more terse by using them. In many places,
> the strerror() calls are still more convenient because, for example,
> they are used in flow debugging functions, or because the return code
> variable of interest is not 'errno'.
> 
> While at it, convert a few error messages from a scant perror style
> to proper failure descriptions.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
>  conf.c      | 31 +++++++++++++++++--------------
>  fwd.c       |  2 +-
>  isolation.c | 28 +++++++++++-----------------
>  log.c       |  2 +-
>  netlink.c   |  4 ++--
>  passt.c     | 12 ++++--------
>  pasta.c     | 32 ++++++++++++++++----------------
>  pcap.c      |  8 +++-----
>  tap.c       | 14 +++++++-------
>  tcp.c       | 24 ++++++++----------------
>  util.c      | 12 +++++-------
>  11 files changed, 75 insertions(+), 94 deletions(-)
> 
> diff --git a/conf.c b/conf.c
> index 344eb07..2a6f05c 100644
> --- a/conf.c
> +++ b/conf.c
> @@ -461,7 +461,7 @@ static void get_dns(struct ctx *c)
>  	}
>  
>  	if (line_len < 0)
> -		warn("Error reading /etc/resolv.conf: %s", strerror(errno));
> +		warn_perror("Error reading /etc/resolv.conf");
>  	close(fd);
>  
>  out:
> @@ -592,8 +592,8 @@ static unsigned int conf_ip4(unsigned int ifi,
>  	if (IN4_IS_ADDR_UNSPECIFIED(&ip4->gw)) {
>  		int rc = nl_route_get_def(nl_sock, ifi, AF_INET, &ip4->gw);
>  		if (rc < 0) {
> -			err("Couldn't discover IPv4 gateway address: %s",
> -			    strerror(-rc));
> +			errno = -rc;

I don't love this.  Taking a re-entrant bit of code and making it
non-reentrant by bouncing information through a global.  I mean, it
works in this case, but still..

-- 
David Gibson (he or they)	| 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:[~2024-06-19  2:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18  7:14 [PATCH v2 0/6] Fixes for early logging/prints and related cleanups Stefano Brivio
2024-06-18  7:14 ` [PATCH v2 1/6] conf, passt: Don't try to log to stderr after we close it Stefano Brivio
2024-06-19  2:14   ` David Gibson
2024-06-19  8:34     ` Stefano Brivio
2024-06-20  0:16       ` David Gibson
2024-06-18  7:14 ` [PATCH v2 2/6] conf, log: Instead of abusing log levels, add log_conf_parsed flag Stefano Brivio
2024-06-18  7:14 ` [PATCH v2 3/6] log, passt: Always print to stderr before initialisation is complete Stefano Brivio
2024-06-18  7:14 ` [PATCH v2 4/6] log: Add _perror() logging function variants Stefano Brivio
2024-06-19  2:21   ` David Gibson
2024-06-19  8:38     ` Stefano Brivio
2024-06-18  7:14 ` [PATCH v2 5/6] treewide: Replace perror() calls with calls to logging functions Stefano Brivio
2024-06-19  2:24   ` David Gibson
2024-06-18  7:14 ` [PATCH v2 6/6] treewide: Replace strerror() calls Stefano Brivio
2024-06-19  2:29   ` David Gibson [this message]
2024-06-19  8:36     ` Stefano Brivio

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=ZnJCclfxf8KGmyZ6@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    --cc=yalzhang@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).