[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-chann
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-channel-command |
Date: |
Thu, 28 Jul 2016 15:44:59 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 07/28/2016 08:37 AM, address@hidden wrote:
> From: Marc-André Lureau <address@hidden>
>
> 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.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> tests/test-io-channel-command.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/tests/test-io-channel-command.c b/tests/test-io-channel-command.c
> index 1d1f461..f99118e 100644
> --- a/tests/test-io-channel-command.c
> +++ b/tests/test-io-channel-command.c
> @@ -18,6 +18,7 @@
> *
> */
>
> +#include <glib/gstdio.h>
> #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 = g_strdup_printf("PIPE:%s,wronly", TEST_FIFO);
> - char *dstfifo = g_strdup_printf("PIPE:%s,rdonly", TEST_FIFO);
> + char *tmpdir = 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 <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v2 03/37] qga: free the whole blacklist, (continued)
- [Qemu-devel] [PATCH v2 04/37] qga: free remaining leaking state, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 06/37] tests: fix test-vmstate leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 05/37] tests: fix test-cutils leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 07/37] tests: fix test-iov leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 08/37] qdist: fix entries memory leak, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 09/37] tests: fix check-qom-interface leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 10/37] tests: fix check-qom-proplist leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-channel-command, marcandre . lureau, 2016/07/28
- Re: [Qemu-devel] [PATCH v2 11/37] tests: fix small leak in test-io-channel-command,
Eric Blake <=
- [Qemu-devel] [PATCH v2 12/37] tests: fix leak in test-string-input-visitor, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 13/37] portio: keep references on portio, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 15/37] pc: simplify passing qemu_irq, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 14/37] numa: do not leak NumaOptions, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 16/37] pc: don't leak a20_line, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 17/37] machine: use class base init generated name, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 18/37] acpi-build: fix array leak, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 19/37] char: disconnect peer when qemu_chr_free(), marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 20/37] char: free MuxDriver when closing, marcandre . lureau, 2016/07/28