From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQpf1-0004RC-AN for qemu-devel@nongnu.org; Wed, 03 Feb 2016 00:07:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQpf0-0000Lt-0J for qemu-devel@nongnu.org; Wed, 03 Feb 2016 00:07:23 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:59105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQpez-0000Le-L3 for qemu-devel@nongnu.org; Wed, 03 Feb 2016 00:07:21 -0500 Date: Wed, 3 Feb 2016 16:04:36 +1100 From: David Gibson Message-ID: <20160203050436.GI15080@voom.fritz.box> References: <145442963048.1539.13602468921796488810.stgit@localhost> <145442963860.1539.7135815311391731257.stgit@localhost> <87twlraqqw.fsf@blackfin.pond.sub.org> <56B123F7.50505@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="l0l+eSofNeLXHSnY" Content-Disposition: inline In-Reply-To: <56B123F7.50505@redhat.com> 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: Thomas Huth Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Markus Armbruster , "Dr . David Alan Gilbert" , =?iso-8859-1?Q?Llu=EDs?= Vilanova --l0l+eSofNeLXHSnY Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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-report.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_ATT= R(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) G= CC_FMT_ATTR(1, 0); > >> +void QEMU_NORETURN error_report_fatal(const char *fmt, ...) GCC_FMT_A= TTR(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, ...). > to do error reporting - which is IMHO the most ugliest way to do this, > because I'd really not expect error_setg() to (always) exit QEMU when I > quickly read through the sources. > We fortunately do not have that in the sources yet (only some few spots > with error_abort), but to prevent that people start using that, it would > be good to have a error_report_fatal() function instead, I think. >=20 > Alternatively, if you really want to see the exit(1) in the sources, I > think this should be mentioned in the coding guidelines ... or are you > fine with error_setg(&error_fatal, ...), Markus? >=20 > Thomas >=20 --=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 --l0l+eSofNeLXHSnY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWsYpkAAoJEGw4ysog2bOSoVEQAN5iszVzU981peQwPI5tCPiq Buv+OUGHdgjKLIj/1UEvoiOhSkNlhcnUWR7sNkfqdFfRJ66ZGI+0fwpTtRn8OJ/F ZMqdfE4C2J38gW3LsfMBm+fptR2gTd4N+z3G6Mho9YB3gIAvURXmL8o05h6+s6Kd Jroshtfhm/QGOn6NyutFNIEDYKZvRKivz9oGPaddOzl1XnJhjiOuezBOxnW4erss aUnVLe/zHeHuqVD2wHN3KGMBw5OU1XEByzflv5SUotWargkoJ3O6qyI30O6vhxSC oX4NmpfaGbe6sRJKAzTDPnn4VsGVTtlarN+2YejwTttUgd5C9lwyXLl1vFOyZpHj 09EOTfrx62W0QljpHzwrmcEGy9iid3Eupd6kn5pDIpN6VWJ/50uJ5K/OX0Gxncms ks9xjGXY9iSUw0oKpX3wviSxNWZJBuscItX7JBUyrlrZpYGTkvXYtjqw7J1zep1b ippnuG4EgaqYusr+4ZJ9mfXz3IC0bJ4WDrlXJkkwjKCXfrLPGbO5GhqeEdcXfYde 4+t2dw03+/dU0ZQrG6B6LE/mh1jF0Wmf2Kk9GW/fgfgcoPnrtEtzUkdTk6O5muLc R3Rt7YS6UUXYY9wYZcvDo6sXSJDMKpBBalCvbDQ6KLNoMpkIIQ3WVuHQb/1UF6sB JBQDufiMa43Ap5u3H8dh =JS26 -----END PGP SIGNATURE----- --l0l+eSofNeLXHSnY--