public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
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 10:36:50 +0200	[thread overview]
Message-ID: <20240619103643.6f7a8eba@elisabeth> (raw)
In-Reply-To: <ZnJCclfxf8KGmyZ6@zatzit>

On Wed, 19 Jun 2024 12:29:06 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

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

Hmm, right, I'll drop this type of change.

-- 
Stefano


      reply	other threads:[~2024-06-19  8:37 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
2024-06-19  8:36     ` Stefano Brivio [this message]

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