]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: use sd_bus_flush_close_unref instead of sd_bus_unref in test-bus-cleanup 2273/head
authorEvgeny Vereshchagin <evvers@ya.ru>
Tue, 5 Jan 2016 15:35:23 +0000 (15:35 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Tue, 5 Jan 2016 15:40:25 +0000 (15:40 +0000)
Fixes:
$ make valgrind-tests TESTS=test-bus-cleanup
==6363== 9 bytes in 1 blocks are possibly lost in loss record 1 of 28
==6363==    at 0x4C2BBCF: malloc (vg_replace_malloc.c:299)
==6363==    by 0x197D12: hexmem (hexdecoct.c:79)
==6363==    by 0x183083: bus_socket_start_auth_client (bus-socket.c:639)
==6363==    by 0x1832A0: bus_socket_start_auth (bus-socket.c:678)
==6363==    by 0x183438: bus_socket_connect (bus-socket.c:705)
==6363==    by 0x14B0F2: bus_start_address (sd-bus.c:1053)
==6363==    by 0x14B592: sd_bus_start (sd-bus.c:1134)
==6363==    by 0x14B95E: sd_bus_open_system (sd-bus.c:1235)
==6363==    by 0x1127E2: test_bus_open (test-bus-cleanup.c:42)
==6363==    by 0x112AAE: main (test-bus-cleanup.c:87)
==6363==
...
$ ./libtool --mode=execute valgrind ./test-bus-cleanup
==6584== LEAK SUMMARY:
...
==6584==      possibly lost: 10,566 bytes in 27 blocks

src/libsystemd/sd-bus/test-bus-cleanup.c

index 1c3ccda3648724c86df623b8fdfabda65782bbd6..cbc450fdb22ea36530143557a5064f323f75e1d1 100644 (file)
@@ -36,7 +36,7 @@ static void test_bus_new(void) {
 }
 
 static int test_bus_open(void) {
-        _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
+        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
         int r;
 
         r = sd_bus_open_system(&bus);
@@ -59,8 +59,8 @@ static void test_bus_new_method_call(void) {
 
         printf("after message_new_method_call: refcount %u\n", REFCNT_GET(bus->n_ref));
 
-        sd_bus_unref(bus);
-        printf("after bus_unref: refcount %u\n", m->n_ref);
+        sd_bus_flush_close_unref(bus);
+        printf("after bus_flush_close_unref: refcount %u\n", m->n_ref);
 }
 
 static void test_bus_new_signal(void) {
@@ -73,8 +73,8 @@ static void test_bus_new_signal(void) {
 
         printf("after message_new_signal: refcount %u\n", REFCNT_GET(bus->n_ref));
 
-        sd_bus_unref(bus);
-        printf("after bus_unref: refcount %u\n", m->n_ref);
+        sd_bus_flush_close_unref(bus);
+        printf("after bus_flush_close_unref: refcount %u\n", m->n_ref);
 }
 
 int main(int argc, char **argv) {