From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAziS-0004BA-8U for qemu-devel@nongnu.org; Tue, 24 Apr 2018 11:18:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAziO-0005N1-1n for qemu-devel@nongnu.org; Tue, 24 Apr 2018 11:18:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50170 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAziN-0005KV-TW for qemu-devel@nongnu.org; Tue, 24 Apr 2018 11:18:43 -0400 Date: Tue, 24 Apr 2018 16:18:30 +0100 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Message-ID: <20180424151830.GI20310@redhat.com> Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= References: <1524156319-11465-1-git-send-email-ian.jackson@eu.citrix.com> <1524156319-11465-16-git-send-email-ian.jackson@eu.citrix.com> <23263.17660.17771.980752@mariner.uk.xensource.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <23263.17660.17771.980752@mariner.uk.xensource.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with error_report List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ian Jackson Cc: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Juergen Gross , Stefano Stabellini , Markus Armbruster , Michael Tokarev , qemu-devel@nongnu.org, Alistair Francis , Ross Lagerwall , xen-devel@lists.xenproject.org, Anthony PERARD , Paolo Bonzini On Tue, Apr 24, 2018 at 03:53:48PM +0100, Ian Jackson wrote: > Philippe Mathieu-Daud=C3=A9 writes ("Re: [Qemu-devel] [PATCH 15/16] os-= posix: cleanup: Replace perror with error_report"): > > On 04/19/2018 01:45 PM, Ian Jackson wrote: > > > - perror("mlockall"); > > > + error_report("mlockall: %s", strerror(errno)); > > > } > > > =20 > > > return ret; > >=20 > > Thinking loudly, maybe we can refactor as error_report_errno(const ch= ar > > *desc)... >=20 > git-grep 'error_report.*errno' shows a lot of call sites that do > something more exciting than const char *desc would support. >=20 > I think the right approach would be >=20 > - static void vreport(report_type type, const char *fmt, va_list ap) > + static void vreport(report_type type, int errnoval, const char *fmt,= va_list ap) > ... > + if (errnoval >=3D 0) { > + error_printf(": %s", strerror(errnoval); > + } >=20 > and then add both > error_report_errno > error_vreport_errno > with the obvious semantics. That would be nice, because then we can make these two functions actually use strerror_r() instead of strerror(), for thread safety on all platform= s. Regards, Daniel --=20 |: https://berrange.com -o- https://www.flickr.com/photos/dberran= ge :| |: https://libvirt.org -o- https://fstop138.berrange.c= om :| |: https://entangle-photo.org -o- https://www.instagram.com/dberran= ge :|