From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR63P-0001B8-JK for qemu-devel@nongnu.org; Wed, 03 Feb 2016 17:37:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aR63J-0000jh-LV for qemu-devel@nongnu.org; Wed, 03 Feb 2016 17:37:39 -0500 Received: from ozlabs.org ([103.22.144.67]:43575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR63J-0000jU-BN for qemu-devel@nongnu.org; Wed, 03 Feb 2016 17:37:33 -0500 Date: Thu, 4 Feb 2016 09:23:44 +1100 From: David Gibson Message-ID: <20160203222344.GS15080@voom.fritz.box> References: <145442963048.1539.13602468921796488810.stgit@localhost> <145442963860.1539.7135815311391731257.stgit@localhost> <87twlraqqw.fsf@blackfin.pond.sub.org> <56B123F7.50505@redhat.com> <20160203050436.GI15080@voom.fritz.box> <87bn7yxgxm.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="K5roPakIqCb4O6y8" Content-Disposition: inline In-Reply-To: <87bn7yxgxm.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH v6 1/5] util: Introduce error reporting functions with fatal/abort List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: =?iso-8859-1?Q?Llu=EDs?= Vilanova , Stefan Hajnoczi , Thomas Huth , qemu-devel@nongnu.org, "Dr . David Alan Gilbert" --K5roPakIqCb4O6y8 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 03, 2016 at 10:48:53AM +0100, Markus Armbruster wrote: > David Gibson writes: >=20 > > On Tue, Feb 02, 2016 at 10:47:35PM +0100, Thomas Huth wrote: > >> On 02.02.2016 19:53, Markus Armbruster wrote: > >> > Llu=EDs Vilanova writes: > >> ... > >>=20 > >> >> diff --git a/include/qemu/error-report.h b/include/qemu/error-repor= t.h > >> >> index 7ab2355..6c2f142 100644 > >> >> --- a/include/qemu/error-report.h > >> >> +++ b/include/qemu/error-report.h > >> >> @@ -43,4 +43,23 @@ void error_report(const char *fmt, ...) GCC_FMT_= ATTR(1, 2); > >> >> const char *error_get_progname(void); > >> >> extern bool enable_timestamp_msg; > >> >> =20 > >> >> +/* Report message and exit with error */ > >> >> +void QEMU_NORETURN error_vreport_fatal(const char *fmt, va_list ap= ) GCC_FMT_ATTR(1, 0); > >> >> +void QEMU_NORETURN error_report_fatal(const char *fmt, ...) GCC_FM= T_ATTR(1, 2); > >> >=20 > >> > This lets people write things like > >> >=20 > >> > error_report_fatal("The sky is falling"); > >> >=20 > >> > instead of > >> >=20 > >> > error_report("The sky is falling"); > >> > exit(1); > >> >=20 > >> > or > >> >=20 > >> > fprintf(stderr, "The sky is falling\n"); > >> > exit(1); > >> >=20 > >> > I don't think that's an improvement in clarity. > >>=20 > >> The problem is not the existing code, but that in a couple of new > >> patches, I've now already seen that people are trying to use > >>=20 > >> error_setg(&error_fatal, ... ); > > > > So, I don't actually see any real advantage to error_report_fatal(...) > > over error_setg(&error_fatal, ...). >=20 > I do. Compare: >=20 > (a) error_report(...); > exit(1); >=20 > (b) error_report_fatal(...); >=20 > (c) error_setg(&error_fatal, ...); >=20 > In my opinion, (a) is clearest: even a relatively clueless reader will > know what exit(1) does, can guess what error_report() approximately > does, and doesn't need to know what it does exactly. (b) is slightly > less obvious, and (c) is positively opaque. >=20 > Let's stick to the obvious (a) and be done with it. I'm fine with that, but I still see no real difference between (b) and (c). --=20 David Gibson | 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 --K5roPakIqCb4O6y8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWsn3vAAoJEGw4ysog2bOSGvEQAKfUl4iMJOo/Qry5BMgMubSN YhUOLM/zgW3SGKM6MSvRDM9QztQjFXh+fp6eum6+wS6iISh59nh7MQc6InymWNQQ 1lxod8u+lPW2sPSIrhB8AJdRMCF/axr2oH11iTVLdNnBBtgqzwiC4L+ZPNLWi6tH UgeOnusMZ3iBQa5xbxvoOzepwu3trpBZ0xXaE4fGReWma0dE5e3Qxf6VtPFvNvuI g0NtF37IKAbH+ZLqtPi/sjG1VB6SnBSt1ZZON9utwyd9hOB1O1MVZCSJqqVxnxPl O6KyNnlhxbi6FCUs04Fis8pDYGfVul7rkPzNEGJ6bRJ3nFozf3n8pjnTSD4gBXBJ AyQFqwiNti6ZApX6xDDmodUI3dwPnDlqeXxDmSc+XTLXTnbt/C0b8GYUWo8gw0lJ MxKLt3c6GWt7m5MCuuTVExboSFeDzU45Vhavlwi6bU5V/F7akV803XKrQlAwcvT7 5sh+uvTkmBgEN4sDOm0hcd9IuCd82nt5Zx/a8DUclNJaBrO446L07iXosVUUytAp 91sMrBgmETJqC1xT0ZzbZY597+vZij/XTP9QVRTSlrObWi1GhushiOsMY9988qZa qVZfFPyUNTyXpmOTsMSruTL++jIeNRNgb+02wlh7HGOAYUsZ3fpFCsCS8Zu5m/vd 8bc5mPlI1d8fbi0C45/Q =Ur9V -----END PGP SIGNATURE----- --K5roPakIqCb4O6y8--