From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSt73-0003kr-CU for qemu-devel@nongnu.org; Thu, 28 Jul 2016 17:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSt6z-0000AA-3F for qemu-devel@nongnu.org; Thu, 28 Jul 2016 17:45:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSt6y-0000A3-RJ for qemu-devel@nongnu.org; Thu, 28 Jul 2016 17:45:01 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6ACFF4E02D for ; Thu, 28 Jul 2016 21:45:00 +0000 (UTC) References: <20160728143808.13707-1-marcandre.lureau@redhat.com> <20160728143808.13707-12-marcandre.lureau@redhat.com> From: Eric Blake Message-ID: <579A7CDB.5060603@redhat.com> Date: Thu, 28 Jul 2016 15:44:59 -0600 MIME-Version: 1.0 In-Reply-To: <20160728143808.13707-12-marcandre.lureau@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="u2Bq82vQIFRLK7XOVsu7G6bxpdshAmfn9" Subject: Re: [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-channel-command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --u2Bq82vQIFRLK7XOVsu7G6bxpdshAmfn9 From: Eric Blake To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Message-ID: <579A7CDB.5060603@redhat.com> Subject: Re: [PATCH v2 11/37] tests: fix small leak in test-io-channel-command References: <20160728143808.13707-1-marcandre.lureau@redhat.com> <20160728143808.13707-12-marcandre.lureau@redhat.com> In-Reply-To: <20160728143808.13707-12-marcandre.lureau@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/28/2016 08:37 AM, marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau >=20 > srcfifo && dstfifo must be freed in error case, however unlink() may > delete a file from a different context. Instead, use mkdtemp()/rmdir() > for the temporary files. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > tests/test-io-channel-command.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) >=20 > diff --git a/tests/test-io-channel-command.c b/tests/test-io-channel-co= mmand.c > index 1d1f461..f99118e 100644 > --- a/tests/test-io-channel-command.c > +++ b/tests/test-io-channel-command.c > @@ -18,6 +18,7 @@ > * > */ > =20 > +#include > #include "qemu/osdep.h" > #include "io/channel-command.h" > #include "io-channel-helpers.h" > @@ -26,11 +27,14 @@ > #ifndef WIN32 > static void test_io_channel_command_fifo(bool async) > { > -#define TEST_FIFO "tests/test-io-channel-command.fifo" > QIOChannel *src, *dst; > QIOChannelTest *test; > - char *srcfifo =3D g_strdup_printf("PIPE:%s,wronly", TEST_FIFO); > - char *dstfifo =3D g_strdup_printf("PIPE:%s,rdonly", TEST_FIFO); > + char *tmpdir =3D g_strdup("/tmp/test-io-channel.XXXXXX"); > + g_assert_nonnull(mkdtemp(tmpdir)); I'm always wary of side effects inside assert(). But if I recall correctly, g_assert_nonnull() is unconditional (there's no way like NDEBUG to completely compile away the side effect), so I guess you're safe, even though I would have stored the results of mkdtemp() in a temporary and only then asserted that the temporary is non-null. Whether or not you clean that up, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --u2Bq82vQIFRLK7XOVsu7G6bxpdshAmfn9 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/ iQEcBAEBCAAGBQJXmnzbAAoJEKeha0olJ0NqfnwH/AqXoDZP1rjL7so/pAkXB6Ak 72/WPCRoliOcNKbuUMtcYeHsC3AR/IDqy5VD7wWUUHBOAS+crFQGHJCZYHmUwNWq qbiiP5lYNI5Qy3q+kKPHNs0eYtbEE5ocVua9UK7Qc/fz1YvcmZcnlPsip3BIcCrV xLQc97dbD4SjsP0zP1KG3KVV3xWxTut8ge/9DaJRqCPXcDAD+9BCNBY1TqyMYDgr bGKqAbQVqB4r5OiAJr89Cwhzi5Uv4xQNtothUR0ysgurg7sLCY4sZZeamsvNWPUv LLVKvqHjwiV7MNxTjI6+U/wovQ8AD/aqOtSv5GdR2BYc7JnQB9pMZUUnaxS+6LE= =WSfJ -----END PGP SIGNATURE----- --u2Bq82vQIFRLK7XOVsu7G6bxpdshAmfn9--