Received: from eggs.gnu.org ([2001:4830:134:3::10]:56161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLtSk-0001ej-38 for qemu-devel@nongnu.org; Wed, 20 Jan 2016 09:10:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLtSe-0007rX-EV for qemu-devel@nongnu.org; Wed, 20 Jan 2016 09:10:18 -0500 Received: from roura.ac.upc.edu ([147.83.33.10]:57200 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLtSe-0007qq-21 for qemu-devel@nongnu.org; Wed, 20 Jan 2016 09:10:12 -0500 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <145286604004.29455.1509463776346981362.stgit@localhost> <145286604762.29455.8630766735054984295.stgit@localhost> <569D4A82.5000506@redhat.com> <569E0422.8040806@redhat.com> Date: Wed, 20 Jan 2016 15:10:09 +0100 In-Reply-To: <569E0422.8040806@redhat.com> (Thomas Huth's message of "Tue, 19 Jan 2016 10:38:42 +0100") Message-ID: <8760yo735q.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 ] doc: Introduce coding style for errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, Markus Armbruster , "Dr . David Alan Gilbert" Thomas Huth writes: > On 18.01.2016 21:26, Eric Blake wrote: >> On 01/15/2016 06:54 AM, Llu=C3=ADs Vilanova wrote: >>> Gives some general guidelines for reporting errors in QEMU. >>>=20 >>> Signed-off-by: Llu=C3=ADs Vilanova >>> --- >>> HACKING | 36 ++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 36 insertions(+) > ... >>> +Functions in this header are used to accumulate error messages in an '= Error' >>> +object, which can be propagated up the call chain where it is finally = reported. >>> + >>> +In its simplest form, you can immediately report an error with: >>> + >>> + error_setg(&error_fatal, "Error with %s", "arguments"); >>=20 >> This paradigm doesn't appear anywhere in the current code base >> (hw/ppc/spapr*.c has a few cases of error_setg(&error_abort), but >> nothing directly passes error_fatal). It's a bit odd to document >> something that isn't actually used. > +1 for _not_ documenting this here: IMHO this looks ugly. If we want > something like this, I think we should introduce a proper > error_report_fatal() function instead. That's a bit of a chicken and egg problem. My main intention was to provide= a best practices summary on reporting messages/errors, since QEMU's code is r= eally heterogeneous on that regard. But there seems to be no consensus on some de= tails of what the proper way should be with the current interfaces. Utility functions for "regular messages", warnings, fatals and aborts would definitiely be an improvement IMHO, but I dont have time to adapt existing = code to these (and I was told not to add unused utility functions for this). Now, if I were able to add such functions, it'd be something like: // Generate message "as is"; not sure if this should exist. message_report(fmt, ...) // Generate message with prepended file/line information for the caller. // Calls exit/abort on the last two. error_report_{warn,fatal,abort}(fmt, ...) // Same with an added message from strerror. error_report_{warn,fatal,abort}_errno(fmt, ...) But, should I add these without providing extensive patches that refactor c= ode to use them? Cheers, Lluis