From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQina-0008Is-0J for qemu-devel@nongnu.org; Tue, 02 Feb 2016 16:47:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQinW-0007OF-05 for qemu-devel@nongnu.org; Tue, 02 Feb 2016 16:47:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQinV-0007Np-Ql for qemu-devel@nongnu.org; Tue, 02 Feb 2016 16:47:41 -0500 References: <145442963048.1539.13602468921796488810.stgit@localhost> <145442963860.1539.7135815311391731257.stgit@localhost> <87twlraqqw.fsf@blackfin.pond.sub.org> From: Thomas Huth Message-ID: <56B123F7.50505@redhat.com> Date: Tue, 2 Feb 2016 22:47:35 +0100 MIME-Version: 1.0 In-Reply-To: <87twlraqqw.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 , =?UTF-8?Q?Llu=c3=ads_Vilanova?= Cc: Stefan Hajnoczi , David Gibson , qemu-devel@nongnu.org, "Dr . David Alan Gilbert" On 02.02.2016 19:53, Markus Armbruster wrote: > Llu=C3=ADs Vilanova writes: ... >> 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. 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 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. 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? Thomas