qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] test-vmstate: Fix memleaks in test_load_qlist
@ 2020-02-20 13:41 kuhn.chenqun
  2020-02-20 14:06 ` Laurent Vivier
  2020-02-27 18:03 ` Juan Quintela
  0 siblings, 2 replies; 3+ messages in thread
From: kuhn.chenqun @ 2020-02-20 13:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: thuth, zhang.zhanghailiang, quintela, qemu-trivial, dgilbert,
	Chen Qun, ehabkost

From: Chen Qun <kuhn.chenqun@huawei.com>

There is memleak in test_load_qlist().It's not a big deal,
but test-vmstate will fail if sanitizers is enabled.

In addition, "ret" is written twice with the same value
 in test_gtree_load_iommu().

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 tests/test-vmstate.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index cea363dd69..f7b3868881 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -1241,7 +1241,6 @@ static void test_gtree_load_iommu(void)
     TestGTreeIOMMU *orig_iommu = create_iommu();
     QEMUFile *fsave, *fload;
     char eof;
-    int ret;
 
     fsave = open_test_file(true);
     qemu_put_buffer(fsave, iommu_dump, sizeof(iommu_dump));
@@ -1250,10 +1249,8 @@ static void test_gtree_load_iommu(void)
 
     fload = open_test_file(false);
     vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1);
-    ret = qemu_file_get_error(fload);
     eof = qemu_get_byte(fload);
-    ret = qemu_file_get_error(fload);
-    g_assert(!ret);
+    g_assert(!qemu_file_get_error(fload));
     g_assert_cmpint(orig_iommu->id, ==, dest_iommu->id);
     g_assert_cmpint(eof, ==, QEMU_VM_EOF);
 
@@ -1395,6 +1392,7 @@ static void test_load_qlist(void)
     compare_containers(orig_container, dest_container);
     free_container(orig_container);
     free_container(dest_container);
+    qemu_fclose(fload);
 }
 
 typedef struct TmpTestStruct {
-- 
2.23.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] test-vmstate: Fix memleaks in test_load_qlist
  2020-02-20 13:41 [PATCH v2] test-vmstate: Fix memleaks in test_load_qlist kuhn.chenqun
@ 2020-02-20 14:06 ` Laurent Vivier
  2020-02-27 18:03 ` Juan Quintela
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2020-02-20 14:06 UTC (permalink / raw)
  To: kuhn.chenqun, qemu-devel
  Cc: thuth, ehabkost, quintela, qemu-trivial, dgilbert,
	zhang.zhanghailiang

Le 20/02/2020 à 14:41, kuhn.chenqun@huawei.com a écrit :
> From: Chen Qun <kuhn.chenqun@huawei.com>
> 
> There is memleak in test_load_qlist().It's not a big deal,
> but test-vmstate will fail if sanitizers is enabled.
> 
> In addition, "ret" is written twice with the same value
>  in test_gtree_load_iommu().
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  tests/test-vmstate.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index cea363dd69..f7b3868881 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -1241,7 +1241,6 @@ static void test_gtree_load_iommu(void)
>      TestGTreeIOMMU *orig_iommu = create_iommu();
>      QEMUFile *fsave, *fload;
>      char eof;
> -    int ret;
>  
>      fsave = open_test_file(true);
>      qemu_put_buffer(fsave, iommu_dump, sizeof(iommu_dump));
> @@ -1250,10 +1249,8 @@ static void test_gtree_load_iommu(void)
>  
>      fload = open_test_file(false);
>      vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1);
> -    ret = qemu_file_get_error(fload);
>      eof = qemu_get_byte(fload);
> -    ret = qemu_file_get_error(fload);
> -    g_assert(!ret);
> +    g_assert(!qemu_file_get_error(fload));/
>      g_assert_cmpint(orig_iommu->id, ==, dest_iommu->id);
>      g_assert_cmpint(eof, ==, QEMU_VM_EOF);
>  
> @@ -1395,6 +1392,7 @@ static void test_load_qlist(void)
>      compare_containers(orig_container, dest_container);
>      free_container(orig_container);
>      free_container(dest_container);
> +    qemu_fclose(fload);
>  }
>  
>  typedef struct TmpTestStruct {
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] test-vmstate: Fix memleaks in test_load_qlist
  2020-02-20 13:41 [PATCH v2] test-vmstate: Fix memleaks in test_load_qlist kuhn.chenqun
  2020-02-20 14:06 ` Laurent Vivier
@ 2020-02-27 18:03 ` Juan Quintela
  1 sibling, 0 replies; 3+ messages in thread
From: Juan Quintela @ 2020-02-27 18:03 UTC (permalink / raw)
  To: kuhn.chenqun
  Cc: thuth, zhang.zhanghailiang, qemu-trivial, qemu-devel, dgilbert,
	ehabkost

<kuhn.chenqun@huawei.com> wrote:
> From: Chen Qun <kuhn.chenqun@huawei.com>
>
> There is memleak in test_load_qlist().It's not a big deal,
> but test-vmstate will fail if sanitizers is enabled.
>
> In addition, "ret" is written twice with the same value
>  in test_gtree_load_iommu().
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

queued



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-27 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-20 13:41 [PATCH v2] test-vmstate: Fix memleaks in test_load_qlist kuhn.chenqun
2020-02-20 14:06 ` Laurent Vivier
2020-02-27 18:03 ` Juan Quintela

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).