From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw3Ts-0007Yv-DB for qemu-devel@nongnu.org; Tue, 10 Nov 2015 02:36:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw3Tp-0000V8-5H for qemu-devel@nongnu.org; Tue, 10 Nov 2015 02:36:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw3To-0000V4-W5 for qemu-devel@nongnu.org; Tue, 10 Nov 2015 02:36:37 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B37F48F4EF for ; Tue, 10 Nov 2015 07:36:36 +0000 (UTC) From: Markus Armbruster References: <1447091204-10226-1-git-send-email-armbru@redhat.com> <1447091204-10226-8-git-send-email-armbru@redhat.com> <5640E098.5090701@redhat.com> Date: Tue, 10 Nov 2015 08:36:34 +0100 In-Reply-To: <5640E098.5090701@redhat.com> (Eric Blake's message of "Mon, 9 Nov 2015 11:06:16 -0700") Message-ID: <8737we4871.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PULL 07/12] qapi: Simplify error cleanup in test-qmp-* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org Eric Blake writes: > On 11/09/2015 10:46 AM, Markus Armbruster wrote: >> From: Eric Blake >> >> We have several tests that perform multiple sub-actions that are >> expected to fail. Asserting that an error occurred, then clearing >> it up to prepare for the next action, turned into enough >> boilerplate that it was sometimes forgotten (for example, a number >> of tests added to test-qmp-input-visitor.c in d88f5fd leaked err). >> Worse, if an error is not reset to NULL, we risk invalidating >> later use of that error (passing a non-NULL err into a function >> is generally a bad idea). Encapsulate the boilerplate into a >> single helper function error_free_or_abort(), and consistently >> use it. >> >> The new function is added into error.c for use everywhere, >> although it is anticipated that testsuites will be the main >> client. >> >> Signed-off-by: Eric Blake >> Signed-off-by: Markus Armbruster >> --- > >> +++ b/include/qapi/error.h >> @@ -30,6 +30,10 @@ >> * Handle an error without reporting it (just for completeness): >> * error_free(err); >> * >> + * Assert than an expected error occurred, but clean it up without >> + * reporting it (primarily useful in testsuites): > > s/than/that/ (if the pull hasn't already gone through; otherwise it's a > trivial followup) Fixed in PULL v2, thanks!