Received: from eggs.gnu.org ([2001:4830:134:3::10]:42444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoVvx-0002Js-5J for qemu-devel@nongnu.org; Thu, 05 Dec 2013 05:13:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoVvo-00056C-U8 for qemu-devel@nongnu.org; Thu, 05 Dec 2013 05:13:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoVvo-000559-Lg for qemu-devel@nongnu.org; Thu, 05 Dec 2013 05:13:16 -0500 From: Markus Armbruster References: <46e453b90b9822456f6ffb97f9c03ccbf36a0214.1386203851.git.peter.crosthwaite@xilinx.com> Date: Thu, 05 Dec 2013 11:13:13 +0100 In-Reply-To: <46e453b90b9822456f6ffb97f9c03ccbf36a0214.1386203851.git.peter.crosthwaite@xilinx.com> (Peter Crosthwaite's message of "Wed, 4 Dec 2013 16:48:25 -0800") Message-ID: <874n6n7ghy.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 1/6] error: Add error_abort List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: imammedo@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, afaerber@suse.de Peter Crosthwaite writes: > Add a special Error * that can be passed to error handling APIs to > signal that any errors are fatal and should abort QEMU. There are two > advantages to this: > > - allows for brevity when wishing to assert success of Error ** > accepting APIs. No need for this pattern: > Error * local_err = NULL; > api_call(foo, bar, &local_err); > assert_no_error(local_err); > This also removes the need for _nofail variants of APIs with > asserting call sites now reduced to 1LOC. > - SIGABRT happens from within the offending API. When a fatal error > occurs in an API call (when the caller is asserting sucess) failure > often means the API itself is broken. With the abort happening in the > API call now, the stack frames into the call are available at debug > time. In the assert_no_error scheme the abort happens after the fact. > > The exact semantic is that when an error is raised, if the argument > Error ** matches &error_abort, then the abort occurs immediately. The > error messaged is reported. > > For error_propagate, if the destination error is &error_abort, then > the abort happens at propagation time. > > Signed-off-by: Peter Crosthwaite > --- > changed since v1: > Delayed assertions that *errp == NULL. Care to explain why you want to delay these assertions? I'm not sure I get it... [...] > @@ -31,7 +33,6 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) > if (errp == NULL) { > return; > } > - assert(*errp == NULL); > > err = g_malloc0(sizeof(*err)); > > @@ -40,6 +41,12 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...) > va_end(ap); > err->err_class = err_class; > > + if (errp == &error_abort) { > + error_report("%s", error_get_pretty(err)); > + abort(); > + } > + > + assert(*errp == NULL); > *errp = err; > } > [...]