From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJNaM-00040I-Iw for qemu-devel@nongnu.org; Wed, 13 Jan 2016 10:43:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJNaJ-00014e-AO for qemu-devel@nongnu.org; Wed, 13 Jan 2016 10:43:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJNaJ-00014T-5L for qemu-devel@nongnu.org; Wed, 13 Jan 2016 10:43:43 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 396E7C076637 for ; Wed, 13 Jan 2016 15:43:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-28.phx2.redhat.com [10.3.113.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0DFheWY014282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 13 Jan 2016 10:43:41 -0500 From: Markus Armbruster Date: Wed, 13 Jan 2016 16:42:59 +0100 Message-Id: <1452699819-26608-2-git-send-email-armbru@redhat.com> In-Reply-To: <1452699819-26608-1-git-send-email-armbru@redhat.com> References: <1452699819-26608-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PULL 01/41] error: Document how to accumulate multiple errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Suggested-by: Eric Blake Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <1447776349-2344-1-git-send-email-armbru@redhat.com> --- include/qapi/error.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/qapi/error.h b/include/qapi/error.h index 6285cf5..1480f59 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