From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 40A235A0053 for ; Thu, 20 Jun 2024 02:13:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718842411; bh=hneJ0iSBUYPxh8KmMfqlocZBHUEbGJgJ+ul3koic+Dc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=e8q3SgNH1mUHxczf2tsX1mqqPmVznb+0DChLiN3y2V0sOq7l6umGaRcGL/CF5PDWK SiTOZhOjCrxtbyDaeMZ2G1JJv/DYLzUga/KnSInOMYnGeQbUGt6m4eXpzsaVY4kIK2 FkTfMPsbCe3YD6uk3MgeU/9RnZD6gh1QndyeRcqdbrpzjbq3hLHah76YjJNqmxu0xP NZR+bSnrOm5UibHYdtNIpC7i6b3k2ppLWlpqeF/9gPDOWuNMuJNwPTlwF+keFfiPWu k7TialFhKs1EJc5tX83oz8ABlGD6z32N8tHF+zNcZut26ws16V1CEQTf4icWiQR+UT NbrDs/N4xOjeQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W4LYl4595z4wyg; Thu, 20 Jun 2024 10:13:31 +1000 (AEST) Date: Thu, 20 Jun 2024 10:13:24 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 4/6] log: Add _perror() logging function variants Message-ID: References: <20240617120319.1206857-1-sbrivio@redhat.com> <20240617120319.1206857-5-sbrivio@redhat.com> <20240618080216.2d873da2@elisabeth> <20240619102509.2a1ecebf@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nW8RwrXORmLvLXw2" Content-Disposition: inline In-Reply-To: <20240619102509.2a1ecebf@elisabeth> Message-ID-Hash: RNKXVKBQJF5PMQ7TUSQJ6JATM4BQOMOZ X-Message-ID-Hash: RNKXVKBQJF5PMQ7TUSQJ6JATM4BQOMOZ 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: --nW8RwrXORmLvLXw2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 19, 2024 at 10:25:17AM +0200, Stefano Brivio wrote: > On Wed, 19 Jun 2024 12:11:51 +1000 > David Gibson wrote: >=20 > > On Tue, Jun 18, 2024 at 08:02:16AM +0200, Stefano Brivio wrote: > > > On Tue, 18 Jun 2024 10:46:36 +1000 > > > David Gibson wrote: > > > =20 > > > > On Mon, Jun 17, 2024 at 02:03:17PM +0200, Stefano Brivio wrote: =20 > > > > > In many places, we have direct perror() calls, which completely b= ypass > > > > > logging functions and log files. > > > > >=20 > > > > > They are definitely convenient: offer similar convenience with > > > > > _perror() logging variants, so that we can drop those direct perr= or() > > > > > calls. > > > > >=20 > > > > > Signed-off-by: Stefano Brivio =20 > > > >=20 > > > > Hm, for anything bigger than like a screenful of code, I generally > > > > find an explicit message with strerror(errno) more useful than > > > > perror() or equivalents, but I guess if you think these are useful.= =20 > > >=20 > > > Okay, yes, it probably makes sense to have more descriptive messages = as > > > you suggest in the comment to 5/6, but even then, we still have a lot > > > of cases like this one (from 6/6): > > >=20 > > > - warn("lseek() failed on /proc/net file: %s", strerror(errno)); > > > + warn_perror("lseek() failed on /proc/net file"); > > >=20 > > > where these _perror() variants make for tidier code, I find, regardle= ss > > > of the error message itself. =20 > >=20 > > Eh, I mildly prefer the first variant. It is slightly longer, but > > makes it very clear where the strerror piece is going to appear in the > > context of the whole message. It's not a strong preference, though. >=20 > Well, it depends. If you're used to perror() it's obvious where the > error description will appear, and it's actually faster for me to read > something called "_perror" than %s plus the argument. Plus we can save > a few lines like that and substantially improve readability in some > cases: >=20 > if (prctl(PR_CAPBSET_DROP, i, 0, 0, 0) && > errno !=3D EINVAL && errno !=3D EPERM) > - die("Couldn't drop cap %i from bounding set: %s", > - i, strerror(errno)); > + die_perror("Couldn't drop cap %i from bounding set", i); Eh, ok. You more or less convinced me. --=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 --nW8RwrXORmLvLXw2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZzdCMACgkQzQJF27ox 2Gdlug//R+afYeLAUAoxXruhUy/O/QXyAYull3kBofjKEy5RhCYc3HGiFWZREiWY Dx2ltIiB+Cx5y8XNuLHXosNDeKfF8M3m07BtrVJlPqhTzmeuXTc1nZDNZUeATxd0 s/Ume9/pqLmRHbWD85vEc0V1N63ZjeqbBF3QlPWdwzWfvZQHPMJzEY6/58eHOmjG lQoY0aaKrH06iUMrhOIqDHBZ/ODSfqt7YNWrk0BqnDVK2noZOe8/wvF/GcYYqiPT VfJ/8Ap7nXeqvYbI8NdxPGU8ZSiaw2tyWEVIZgORcnaxyGp9+SPQ38D0pizPWY6D BSabEgAM2IRNq35B7dsTAKcGS1TOLR3TY9jwODMArrDZPSqzTB3nkBepXvcR/220 qKNmIqiLLtabfFHE+l0UoNi3wZP2pq0Nry9zddWyOsXNr3jyoKRob643YdsFtn+d IoFe50f6YMnIEvGPoFz88pMxTFhM3rGkf1bpM0UglY4iWflHyKdA7pMSfrDaQgma EZBFDEgbozrfYNVP6UpL0NopxZ0xs2bCtje7u0ZMTYs2BGY0wp3D+B98JtBK+jMv 9b7wNwoLXLR5yjAiCi0HrCHgcbs5FrlV4ypPSsV84SJ2PwMFmLGpOn2x7af1tC23 4/z+vbdfKuVxLWi6DYDRD+D3HXKL4U+GkR8bZMPXX513ZXTcnpw= =478c -----END PGP SIGNATURE----- --nW8RwrXORmLvLXw2--