From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZujwF-0004Ey-QO for qemu-devel@nongnu.org; Fri, 06 Nov 2015 11:32:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZujwD-0007tc-3b for qemu-devel@nongnu.org; Fri, 06 Nov 2015 11:32:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZujwC-0007tG-SP for qemu-devel@nongnu.org; Fri, 06 Nov 2015 11:32:29 -0500 References: <1446791754-23823-1-git-send-email-eblake@redhat.com> <1446791754-23823-8-git-send-email-eblake@redhat.com> <871tc316gn.fsf@blackfin.pond.sub.org> <563CCE4F.6060809@redhat.com> <87fv0jw0ys.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <563CD61B.4040700@redhat.com> Date: Fri, 6 Nov 2015 09:32:27 -0700 MIME-Version: 1.0 In-Reply-To: <87fv0jw0ys.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ihn9EFA6s4mkj4pW06O8VULGrRcW7N1JG" Subject: Re: [Qemu-devel] [PATCH v10 07/30] qapi: Simplify error cleanup in test-qmp-* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ihn9EFA6s4mkj4pW06O8VULGrRcW7N1JG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/06/2015 09:23 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> On 11/06/2015 08:40 AM, Markus Armbruster wrote: >>> Eric Blake writes: >>> >>>> By moving err into data, we can let test teardown take care >>>> of cleaning up any collected error; it also gives us fewer >>>> lines of code between repeated tests where init runs teardown >>>> on our behalf. >>> >>> I think this paragraph is no longer valid: you aren't moving err >>> anywhere in this version. >> >> D'oh. I scrubbed the code, but not the commit message. At least it wa= s >> a faithful split of the v9 version of the commit, before I reworked th= e >> mechanism :) >> >> How about: >> >> 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, >=20 > If you got suitable commit SHAs handy, lets insert some here. A number of them were introduced in d88f5fd (look at test-qmp-input-visitor.c:test_validate_fail_struct_nested(), for example), and only barely cleaned up in 5/30 of this series. I'm not finding other commits off-hand, though. >=20 >> risking memory leak or invalidating the effor= ts >> of the second action (passing a non-NULL err into a function is >> generally a bad idea). Encapsulate the boilerplate into a single help= er >> function error_free_or_abort(), and consistently use it. >=20 > Works for me. >=20 >>>> Rather than duplicate code between .c files, I added a new >>>> test-qmp-common.h. I debated about putting >>>> error_free_or_abort() in error.h, but it seems like something >>>> that is only useful for tests. >>> >>> Maybe, maybe not. I'd accept it into error.h. >> >> Do you want me to post a fixup patch that relocates it into error.h? >=20 > I guess the result would be slightly simpler, so go ahead. Coming up soon. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ihn9EFA6s4mkj4pW06O8VULGrRcW7N1JG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWPNYbAAoJEKeha0olJ0Nq8MQH/jNSAsAEPmH+I5wv/aPJxTHp 6rop929xninJSwbTVuFUtSow9HlZhDIXigcSA/byQjP4psvpe0976MPj4s14z41P PaPHxPHsvQNdqoiFjwrItIlUc/ZfwNI8J6qPghLKNrUWpMjEha+hEFTYuGw9Klv6 FKyc936Z7Y2ygQO0LwOgZFjIZvC0oHaQW/50ZoOEeGkjb+ouhPtX0QmaO3txCoKX eNhMDlXlHJQoTPVdM7LVJZ9UncvAdNp9gf5KU02I4Jz8tO8b7Ibydcej1stNY6ta GqVD5gF/AV1Oy0540TaY8cfDn+btw4HHp6RrCDkoY5uoHIzr6/Tk6yr3TIJzAtE= =0yr7 -----END PGP SIGNATURE----- --ihn9EFA6s4mkj4pW06O8VULGrRcW7N1JG--