qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: "Marc Marí" <marc.mari.barcelo@gmail.com>
Cc: qemu-devel@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
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	[thread overview]
Message-ID: <20141117152110.GG16192@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1414861350-13099-3-git-send-email-marc.mari.barcelo@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]

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í <marc.mari.barcelo@gmail.com>
> ---
>  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!

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2014-11-17 15:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-01 17:02 [Qemu-devel] [PATCH v2 0/5] libqos: Virtio MMIO driver Marc Marí
2014-11-01 17:02 ` [Qemu-devel] [PATCH v2 1/5] libqos: Change use of pointers to uint64_t in virtio Marc Marí
2014-11-17 15:16   ` Stefan Hajnoczi
2014-11-17 15:19     ` Marc Marí
2014-11-17 15:25       ` Andreas Färber
2014-11-18 14:05         ` Stefan Hajnoczi
2014-11-01 17:02 ` [Qemu-devel] [PATCH v2 2/5] tests: Prepare virtio-blk-test for multi-arch implementation Marc Marí
2014-11-17 15:21   ` Stefan Hajnoczi [this message]
2014-11-01 17:02 ` [Qemu-devel] [PATCH v2 3/5] libqos: Remove PCI assumptions in constants of virtio driver Marc Marí
2014-11-01 17:02 ` [Qemu-devel] [PATCH v2 4/5] libqos: Add malloc generic Marc Marí
2014-11-17 15:30   ` Stefan Hajnoczi
2014-11-01 17:02 ` [Qemu-devel] [PATCH v2 5/5] libqos: Add virtio MMIO support Marc Marí
2014-11-17 15:48   ` Stefan Hajnoczi
2014-11-23 11:41     ` Marc Marí
2014-11-24 11:59       ` Stefan Hajnoczi
2014-11-24 12:30         ` Marc Marí
2014-11-17  9:26 ` [Qemu-devel] [PATCH v2 0/5] libqos: Virtio MMIO driver Marc Marí

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141117152110.GG16192@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=afaerber@suse.de \
    --cc=marc.mari.barcelo@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).