From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0AEE15A004F for ; Wed, 19 Jun 2024 04:34:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718764462; bh=yPbs5QWVkM/N65Cs1oQrvHUvs5vEYWX023Se/2gEziU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NP6a2T4tKdxfrxKFpNKZjqoyBP5du0CBggiIs4A0oENEetpZTziEF/33xsOGpMW9H evZDNApP5JXQ3LV+Kraa4tcW5QRpnB+5zr+TMU0COkhxgZRNE31w2emflkB+038cT0 uddHhMdyS501zdOMbVxC8vj+Gm2rlQAIMekrSNV0pUzD7Z0FmA/4T7PMoT1zhmB8HD ZMahUFGp3N/0VxEUdfQ763r1zhCaXsOQ4OQN/Dt1g/94DFyW9SUWZukNjs47BAwDfD Kgd0jyaxU1GJr6Y2c0oIasW43Ehd8ImWoDLOJDvbZ597lQ1KduO7n7IFWhogr9UGO9 nvyvoLgBFjMsQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W3nkk462fz4wyg; Wed, 19 Jun 2024 12:34:22 +1000 (AEST) Date: Wed, 19 Jun 2024 12:29:06 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 6/6] treewide: Replace strerror() calls Message-ID: References: <20240618071427.1544869-1-sbrivio@redhat.com> <20240618071427.1544869-7-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="a3uqcfa7ZFYmWYH+" Content-Disposition: inline In-Reply-To: <20240618071427.1544869-7-sbrivio@redhat.com> Message-ID-Hash: 5EMAUOLYJWKHOMP4VFENYAD6PNHFKKC6 X-Message-ID-Hash: 5EMAUOLYJWKHOMP4VFENYAD6PNHFKKC6 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, Yalan Zhang 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: --a3uqcfa7ZFYmWYH+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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'. >=20 > While at it, convert a few error messages from a scant perror style > to proper failure descriptions. >=20 > Signed-off-by: Stefano Brivio > --- > 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(-) >=20 > 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) > } > =20 > if (line_len < 0) > - warn("Error reading /etc/resolv.conf: %s", strerror(errno)); > + warn_perror("Error reading /etc/resolv.conf"); > close(fd); > =20 > out: > @@ -592,8 +592,8 @@ static unsigned int conf_ip4(unsigned int ifi, > if (IN4_IS_ADDR_UNSPECIFIED(&ip4->gw)) { > int rc =3D 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 =3D -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.. --=20 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 --a3uqcfa7ZFYmWYH+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZyQnEACgkQzQJF27ox 2GdmuRAAiLM4zpYmJCt71OSrqNztn6uqexhAOY5C57QaXQO/etuOjOBkQv5QEuKa NARxfO13NIQbTa87SwRWhhxyz64GcX1k42r2UnFyx5d3ETcvcdBr3lobOgJw/Emj a6kyUFaaeJtxl3sAYA5KWXnoNeoFYwWdDUvPMEwOnMKOm5r3xcC08Ysb1FZ9/r3A 7KicvZe5XnY902p/I1miWEocXtPSjOGsyCHlzP9yZJqX8ytiQ7cxsuQXYMz4IcXJ 8VuHtlyotmTMMbpVSCo7W7Jo8EVivIbgreTLMHgpgFHZXqrFRvqYLCcx+bzy0V5k LHbXryk202taDkVaFKhkwfIMvzW5wf+1oACZCVUXJsVTbyiI14ESOTLeSQAcGOJp /0OQ9OqqwF4LcNrLvjzytYFgV6Ai0jq7ZcvTxLbbdYIMgKnSOWek1Su05umU3WXK 51qXneBa7NPOgjbm2HSodxfWsLcxFvVW224AGrwxLGSyXHr0YeBKtzfU7wYj7YKp 6vq8c3Nl19yU0HIeaXeDArAfYPtvNU5nvjxdcoe9OQxPSPhPZ/jEa7DjyPzJp3/K MhMNv+wYyVbfElW296fws2ykHovawR1qLwTAoepuTLtoany/uphcj0382UnFNjJD cqD856wagC8L6b6LLQCFvETW7bRp0t5iukGv7SLG8CArvvQdbas= =ULlj -----END PGP SIGNATURE----- --a3uqcfa7ZFYmWYH+--