From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqO7D-0001oc-BO for qemu-devel@nongnu.org; Mon, 17 Nov 2014 10:21:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqO77-0000wF-P2 for qemu-devel@nongnu.org; Mon, 17 Nov 2014 10:21:19 -0500 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:39213) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqO77-0000w5-J0 for qemu-devel@nongnu.org; Mon, 17 Nov 2014 10:21:13 -0500 Received: by mail-wi0-f181.google.com with SMTP id r20so3012055wiv.14 for ; Mon, 17 Nov 2014 07:21:12 -0800 (PST) Date: Mon, 17 Nov 2014 15:21:10 +0000 From: Stefan Hajnoczi Message-ID: <20141117152110.GG16192@stefanha-thinkpad.redhat.com> References: <1414861350-13099-1-git-send-email-marc.mari.barcelo@gmail.com> <1414861350-13099-3-git-send-email-marc.mari.barcelo@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hTiIB9CRvBOLTyqY" Content-Disposition: inline In-Reply-To: <1414861350-13099-3-git-send-email-marc.mari.barcelo@gmail.com> Subject: Re: [Qemu-devel] [PATCH v2 2/5] tests: Prepare virtio-blk-test for multi-arch implementation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marc =?iso-8859-1?Q?Mar=ED?= Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Andreas =?iso-8859-1?Q?F=E4rber?= --hTiIB9CRvBOLTyqY Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 01, 2014 at 06:02:27PM +0100, Marc Mar=ED wrote: > Modularize functions in virtio-blk-test and add PCI suffix for PCI specif= ic > components. >=20 > Signed-off-by: Marc Mar=ED > --- > tests/virtio-blk-test.c | 57 +++++++++++++++++++++++++++++++----------= ------ > 1 file changed, 38 insertions(+), 19 deletions(-) >=20 > diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c > index 33e8094..6f07d5a 100644 > --- a/tests/virtio-blk-test.c > +++ b/tests/virtio-blk-test.c > @@ -55,11 +55,11 @@ typedef struct QVirtioBlkReq { > uint8_t status; > } QVirtioBlkReq; > =20 > -static QPCIBus *test_start(void) > +static char *drive_create(void) > { > - char *cmdline; > - char tmp_path[] =3D "/tmp/qtest.XXXXXX"; > int fd, ret; > + char *tmp_path =3D malloc(18); > + strncpy(tmp_path, "/tmp/qtest.XXXXXX", 18); Please use g_strdup(): https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#= g-strdup QEMU does not use malloc(3)/free(3) directly. Always use glib memory allocation (in this case g_strdup() allocates memory for you). > =20 > /* Create a temporary raw image */ > fd =3D mkstemp(tmp_path); > @@ -68,6 +68,16 @@ static QPCIBus *test_start(void) > g_assert_cmpint(ret, =3D=3D, 0); > close(fd); > =20 > + return tmp_path; > +} > + > +static QPCIBus *pci_test_start(void) > +{ > + char *cmdline; > + char *tmp_path; > + > + tmp_path =3D drive_create(); It seems tmp_path is leaked. You must free dynamically allocated memory! --hTiIB9CRvBOLTyqY Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUahJmAAoJEJykq7OBq3PINEkH/32TzVoJ43w0LG9keAfDOiYx tHjm6MJBDIApc876Ji0ZxL5oJ0BpP6bSLFA+FHbJ1g7zW2GTq76h6hhPOMzTREir CkZtriWRG3uBmS5tb8IYLKRnKeR7OZe1xsYYd7YGvIvRM1b/m/CpY6ILaMBS+GGn fls2MnzgYZ45bydruz9PnH63ygH48aAfjmT3Gl+etbABNRj+w3Xq5jjRmi0c6m3b bA6GOfEQvNQdTN8+7k+EiuJsi3gqj9wM1b+E4E+EoiO17bawnswtDej6mxiUl7LY 1Rx+Ust10Eu2JOPvwM4Z/jwnOAGOfFMkPdq2RZCWvRvv+oXqx2US3tDuNx///mE= =x0xm -----END PGP SIGNATURE----- --hTiIB9CRvBOLTyqY--