qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@163.com>
To: vyasevic@redhat.com, dgilbert@redhat.com, mst@redhat.com,
	jasowang@redhat.com
Cc: qemu-devel@nongnu.org, liq3ea@gmail.com, Li Qiang <liq3ea@163.com>
Subject: [Qemu-devel] [PATCH] tests: test-announce-self: fix memory leak
Date: Sun, 10 Mar 2019 06:12:05 -0700	[thread overview]
Message-ID: <20190310131205.75856-1-liq3ea@163.com> (raw)

Spotted by ASAN when 'make check'.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 tests/test-announce-self.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/tests/test-announce-self.c b/tests/test-announce-self.c
index 1644d34a3f..3f370d8bf5 100644
--- a/tests/test-announce-self.c
+++ b/tests/test-announce-self.c
@@ -21,17 +21,6 @@
 #define ETH_P_RARP 0x8035
 #endif
 
-static QTestState *test_init(int socket)
-{
-    char *args;
-
-    args = g_strdup_printf("-netdev socket,fd=%d,id=hs0 -device "
-                           "virtio-net-pci,netdev=hs0", socket);
-
-    return qtest_start(args);
-}
-
-
 static void test_announce(int socket)
 {
     char buffer[60];
@@ -58,19 +47,22 @@ static void test_announce(int socket)
 
 static void setup(gconstpointer data)
 {
-    QTestState *qs;
     void (*func) (int socket) = data;
     int sv[2], ret;
+    char *args;
 
     ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv);
     g_assert_cmpint(ret, !=, -1);
 
-    qs = test_init(sv[1]);
+    args = g_strdup_printf("-netdev socket,fd=%d,id=hs0 -device "
+                           "virtio-net-pci,netdev=hs0", sv[1]);
+    qtest_start(args);
     func(sv[0]);
 
     /* End test */
     close(sv[0]);
-    qtest_quit(qs);
+    qtest_end();
+    g_free(args);
 }
 
 int main(int argc, char **argv)
-- 
2.17.1

             reply	other threads:[~2019-03-10 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-10 13:12 Li Qiang [this message]
2019-03-11  8:29 ` [Qemu-devel] [PATCH] tests: test-announce-self: fix memory leak Thomas Huth

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=20190310131205.75856-1-liq3ea@163.com \
    --to=liq3ea@163.com \
    --cc=dgilbert@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vyasevic@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).