[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 2/5] tests: Prepare virtio-blk-test for multi
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v2 2/5] tests: Prepare virtio-blk-test for multi-arch implementation |
Date: |
Mon, 17 Nov 2014 15:21:10 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Sat, Nov 01, 2014 at 06:02:27PM +0100, Marc Marí wrote:
> Modularize functions in virtio-blk-test and add PCI suffix for PCI specific
> components.
>
> Signed-off-by: Marc Marí <address@hidden>
> ---
> tests/virtio-blk-test.c | 57
> +++++++++++++++++++++++++++++++----------------
> 1 file changed, 38 insertions(+), 19 deletions(-)
>
> 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;
>
> -static QPCIBus *test_start(void)
> +static char *drive_create(void)
> {
> - char *cmdline;
> - char tmp_path[] = "/tmp/qtest.XXXXXX";
> int fd, ret;
> + char *tmp_path = 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).
>
> /* Create a temporary raw image */
> fd = mkstemp(tmp_path);
> @@ -68,6 +68,16 @@ static QPCIBus *test_start(void)
> g_assert_cmpint(ret, ==, 0);
> close(fd);
>
> + return tmp_path;
> +}
> +
> +static QPCIBus *pci_test_start(void)
> +{
> + char *cmdline;
> + char *tmp_path;
> +
> + tmp_path = drive_create();
It seems tmp_path is leaked. You must free dynamically allocated
memory!
pgp2973mYBWin.pgp
Description: PGP signature
[Qemu-devel] [PATCH v2 4/5] libqos: Add malloc generic, Marc Marí, 2014/11/01
[Qemu-devel] [PATCH v2 2/5] tests: Prepare virtio-blk-test for multi-arch implementation, Marc Marí, 2014/11/01
- Re: [Qemu-devel] [PATCH v2 2/5] tests: Prepare virtio-blk-test for multi-arch implementation,
Stefan Hajnoczi <=
[Qemu-devel] [PATCH v2 3/5] libqos: Remove PCI assumptions in constants of virtio driver, Marc Marí, 2014/11/01
[Qemu-devel] [PATCH v2 5/5] libqos: Add virtio MMIO support, Marc Marí, 2014/11/01
Re: [Qemu-devel] [PATCH v2 0/5] libqos: Virtio MMIO driver, Marc Marí, 2014/11/17