From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1nlR-0003ie-OY for qemu-devel@nongnu.org; Wed, 25 Nov 2015 23:02:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1nlO-0007X8-JL for qemu-devel@nongnu.org; Wed, 25 Nov 2015 23:02:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1nlO-0007X3-E9 for qemu-devel@nongnu.org; Wed, 25 Nov 2015 23:02:30 -0500 Date: Thu, 26 Nov 2015 12:02:25 +0800 From: Fam Zheng Message-ID: <20151126040225.GD14630@ad.usersys.redhat.com> References: <1447776349-2344-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447776349-2344-1-git-send-email-armbru@redhat.com> Subject: Re: [Qemu-devel] [PATCH] error: Document how to accumulate multiple errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com On Tue, 11/17 17:05, Markus Armbruster wrote: > Suggested-by: Eric Blake > Signed-off-by: Markus Armbruster > Reviewed-by: Eric Blake > --- > include/qapi/error.h | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/include/qapi/error.h b/include/qapi/error.h > index 4d42cdc..b2362a5 100644 > --- a/include/qapi/error.h > +++ b/include/qapi/error.h > @@ -76,6 +76,23 @@ > * But when all you do with the error is pass it on, please use > * foo(arg, errp); > * for readability. > + * > + * Receive and accumulate multiple errors (first one wins): > + * Error *err = NULL, *local_err = NULL; > + * foo(arg, &err); > + * bar(arg, &local_err); > + * error_propagate(&err, local_err); > + * if (err) { > + * handle the error... > + * } > + * > + * Do *not* "optimize" this to > + * foo(arg, &err); > + * bar(arg, &err); // WRONG! > + * if (err) { > + * handle the error... > + * } > + * because this may pass a non-null err to bar(). > */ > > #ifndef ERROR_H > -- > 2.4.3 > > Curious if there is a recommended way to report both error messages to caller, rather than overwriting the first with the second? Fam