diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index 90be0e281dfd873582bc6259860770b87bda3d2e..2464c33bf37e4e753341ba1f815f9122d2d8803f 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -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