]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Resolve valgrind error
authorJohn Ferlan <jferlan@redhat.com>
Mon, 15 Apr 2013 15:50:59 +0000 (11:50 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 16 Apr 2013 11:13:43 +0000 (07:13 -0400)
Commit id '1acfc171' resulted in the following valgrind failure:

==25317== 136 (24 direct, 112 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 4
==25317==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
==25317==    by 0x4C6F851: virAlloc (viralloc.c:124)
==25317==    by 0x4C71493: virBitmapNew (virbitmap.c:74)
==25317==    by 0x4C71B79: virBitmapNewData (virbitmap.c:434)
==25317==    by 0x402EF2: test8 (virbitmaptest.c:436)
==25317==    by 0x40499F: virtTestRun (testutils.c:157)
==25317==    by 0x402E8D: mymain (virbitmaptest.c:474)
==25317==    by 0x404FDA: virtTestMain (testutils.c:719)
==25317==    by 0x39D0821A04: (below main) (in /usr/lib64/libc-2.16.so)

tests/virbitmaptest.c

index 90be0e281dfd873582bc6259860770b87bda3d2e..2464c33bf37e4e753341ba1f815f9122d2d8803f 100644 (file)
@@ -432,24 +432,25 @@ static int test8(const void *v ATTRIBUTE_UNUSED)
 {
     virBitmapPtr bitmap = NULL;
     char data[108] = {0x00,};
+    int ret = -1;
 
     bitmap = virBitmapNewData(data, sizeof(data));
     if (!bitmap)
-        goto error;
+        goto cleanup;
 
     if (!virBitmapIsAllClear(bitmap))
-        goto error;
+        goto cleanup;
 
     if (virBitmapSetBit(bitmap, 11) < 0)
-        goto error;
+        goto cleanup;
 
     if (virBitmapIsAllClear(bitmap))
-        goto error;
+        goto cleanup;
 
-    return 0;
-error:
+    ret = 0;
+cleanup:
     virBitmapFree(bitmap);
-    return -1;
+    return ret;
 }
 
 static int