diff options
Diffstat (limited to 'unit/test-gobex-transfer.c')
-rw-r--r-- | unit/test-gobex-transfer.c | 453 |
1 files changed, 263 insertions, 190 deletions
diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c index 4f652dea8..4fc97f454 100644 --- a/unit/test-gobex-transfer.c +++ b/unit/test-gobex-transfer.c @@ -270,7 +270,6 @@ static void test_put_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, @@ -281,11 +280,11 @@ static void test_put_req(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -299,9 +298,12 @@ static void test_put_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -347,7 +349,6 @@ static void test_put_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, @@ -358,11 +359,11 @@ static void test_put_rsp(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put, &d); @@ -376,9 +377,12 @@ static void test_put_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -413,7 +417,6 @@ static void test_stream_put_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, @@ -428,11 +431,11 @@ static void test_stream_put_rsp(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d); @@ -447,9 +450,12 @@ static void test_stream_put_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -475,7 +481,6 @@ static void test_stream_put_req_abort(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, @@ -485,11 +490,11 @@ static void test_stream_put_req_abort(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); d.id = g_obex_put_req(obex, abort_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -503,9 +508,12 @@ static void test_stream_put_req_abort(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED); @@ -516,7 +524,6 @@ static void test_stream_put_rsp_abort(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, @@ -531,11 +538,11 @@ static void test_stream_put_rsp_abort(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d); @@ -549,9 +556,12 @@ static void test_stream_put_rsp_abort(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_error(d.err, G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED); @@ -584,7 +594,6 @@ static void test_packet_put_rsp_wait(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first_srm_wait, sizeof(put_rsp_first_srm_wait) }, @@ -599,11 +608,11 @@ static void test_packet_put_rsp_wait(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq_wait, &d); @@ -619,9 +628,12 @@ static void test_packet_put_rsp_wait(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -631,7 +643,6 @@ static void test_packet_put_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first_srm, sizeof(put_rsp_first_srm) }, @@ -646,11 +657,11 @@ static void test_packet_put_rsp(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_seq, &d); @@ -665,9 +676,12 @@ static void test_packet_put_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -677,7 +691,6 @@ static void test_get_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first, sizeof(get_req_first) }, @@ -688,11 +701,11 @@ static void test_get_req(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -706,9 +719,12 @@ static void test_get_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -718,7 +734,6 @@ static void test_stream_get_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first, sizeof(get_req_first) }, @@ -733,11 +748,11 @@ static void test_stream_get_req(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -751,9 +766,12 @@ static void test_stream_get_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -763,7 +781,6 @@ static void test_packet_get_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm, sizeof(get_req_first_srm) }, @@ -778,11 +795,11 @@ static void test_packet_get_req(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -796,9 +813,12 @@ static void test_packet_get_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -808,7 +828,6 @@ static void test_packet_get_req_wait(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm_wait, sizeof(get_req_first_srm_wait) }, @@ -823,11 +842,11 @@ static void test_packet_get_req_wait(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -842,9 +861,12 @@ static void test_packet_get_req_wait(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -867,7 +889,6 @@ static void test_packet_get_req_suspend_resume(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm, sizeof(get_req_first_srm) }, @@ -884,11 +905,11 @@ static void test_packet_get_req_suspend_resume(void) d.provide_delay = 1; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq_delay, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -902,9 +923,12 @@ static void test_packet_get_req_suspend_resume(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -914,7 +938,6 @@ static void test_packet_get_req_wait_next(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_srm, sizeof(get_req_first_srm) }, @@ -930,11 +953,11 @@ static void test_packet_get_req_wait_next(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -948,9 +971,12 @@ static void test_packet_get_req_wait_next(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -960,7 +986,6 @@ static void test_get_req_app(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first_app, sizeof(get_req_first_app) }, @@ -973,11 +998,11 @@ static void test_get_req_app(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -992,9 +1017,12 @@ static void test_get_req_app(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1043,7 +1071,6 @@ static void test_stream_put_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1059,11 +1086,11 @@ static void test_stream_put_req(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -1077,9 +1104,12 @@ static void test_stream_put_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1117,7 +1147,6 @@ static void test_packet_put_req_suspend_resume(void) { GIOChannel *io; GIOCondition cond; - guint io_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1134,7 +1163,7 @@ static void test_packet_put_req_suspend_resume(void) d.provide_delay = 1; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); @@ -1150,8 +1179,10 @@ static void test_packet_put_req_suspend_resume(void) g_main_loop_unref(d.mainloop); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1161,7 +1192,6 @@ static void test_packet_put_req_wait(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1177,11 +1207,11 @@ static void test_packet_put_req_wait(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -1195,9 +1225,12 @@ static void test_packet_put_req_wait(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1207,7 +1240,6 @@ static void test_packet_put_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1223,11 +1255,11 @@ static void test_packet_put_req(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_seq, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -1241,9 +1273,12 @@ static void test_packet_put_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1253,7 +1288,6 @@ static void test_put_req_eagain(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, @@ -1266,11 +1300,11 @@ static void test_put_req_eagain(void) d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_eagain, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -1284,9 +1318,12 @@ static void test_put_req_eagain(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1296,7 +1333,6 @@ static void test_get_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first, sizeof(get_rsp_first) }, @@ -1307,11 +1343,11 @@ static void test_get_rsp(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d); @@ -1325,9 +1361,12 @@ static void test_get_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1357,7 +1396,6 @@ static void test_stream_get_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1371,11 +1409,11 @@ static void test_stream_get_rsp(void) create_endpoints(&obex, &io, SOCK_STREAM); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq, &d); @@ -1389,9 +1427,12 @@ static void test_stream_get_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1401,7 +1442,6 @@ static void test_packet_get_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1415,11 +1455,11 @@ static void test_packet_get_rsp(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq, &d); @@ -1434,9 +1474,12 @@ static void test_packet_get_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1468,7 +1511,6 @@ static void test_packet_get_rsp_wait(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { NULL, 0 }, @@ -1482,11 +1524,11 @@ static void test_packet_get_rsp_wait(void) create_endpoints(&obex, &io, SOCK_SEQPACKET); cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_seq_srm_wait, &d); @@ -1502,9 +1544,12 @@ static void test_packet_get_rsp_wait(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1537,7 +1582,6 @@ static void test_get_rsp_app(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first_app, sizeof(get_rsp_first_app) }, @@ -1551,11 +1595,11 @@ static void test_get_rsp_app(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_app, &d); @@ -1569,9 +1613,12 @@ static void test_get_rsp_app(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1581,7 +1628,6 @@ static void test_put_req_delay(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_req_first, sizeof(put_req_first) }, @@ -1594,11 +1640,11 @@ static void test_put_req_delay(void) d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_put_req(obex, provide_data, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -1612,9 +1658,12 @@ static void test_put_req_delay(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1624,7 +1673,6 @@ static void test_get_rsp_delay(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first, sizeof(get_rsp_first) }, @@ -1637,11 +1685,11 @@ static void test_get_rsp_delay(void) d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get, &d); @@ -1655,9 +1703,12 @@ static void test_get_rsp_delay(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1708,7 +1759,6 @@ static void test_put_rsp_delay(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { put_rsp_first, sizeof(put_rsp_first) }, @@ -1721,11 +1771,11 @@ static void test_put_rsp_delay(void) d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_PUT, handle_put_delay, &d); @@ -1739,9 +1789,12 @@ static void test_put_rsp_delay(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1751,7 +1804,6 @@ static void test_get_req_delay(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_req_first, sizeof(get_req_first) }, @@ -1764,11 +1816,11 @@ static void test_get_req_delay(void) d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_get_req(obex, rcv_data_delay, transfer_complete, &d, &d.err, G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type), @@ -1782,9 +1834,12 @@ static void test_get_req_delay(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1794,7 +1849,6 @@ static void test_get_rsp_eagain(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { get_rsp_first, sizeof(get_rsp_first) }, @@ -1807,11 +1861,11 @@ static void test_get_rsp_eagain(void) d.provide_delay = 200; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_GET, handle_get_eagain, &d); @@ -1826,9 +1880,12 @@ static void test_get_rsp_eagain(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1849,7 +1906,6 @@ static void test_conn_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) } }, { @@ -1859,11 +1915,11 @@ static void test_conn_req(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete, &d, &d.err, G_OBEX_HDR_INVALID); g_assert_no_error(d.err); @@ -1874,9 +1930,12 @@ static void test_conn_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1906,7 +1965,6 @@ static void test_conn_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) } }, { @@ -1916,11 +1974,11 @@ static void test_conn_rsp(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); @@ -1935,10 +1993,12 @@ static void test_conn_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - if (!d.io_completed) - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -1964,7 +2024,6 @@ static void test_conn_get_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) }, @@ -1978,11 +2037,11 @@ static void test_conn_get_req(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_get_req, &d, &d.err, G_OBEX_HDR_INVALID); @@ -1994,9 +2053,12 @@ static void test_conn_get_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -2006,7 +2068,6 @@ static void test_conn_get_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) }, @@ -2020,11 +2081,11 @@ static void test_conn_get_rsp(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); @@ -2042,9 +2103,12 @@ static void test_conn_get_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -2070,7 +2134,6 @@ static void test_conn_put_req(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) }, @@ -2084,11 +2147,11 @@ static void test_conn_put_req(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_put_req, &d, &d.err, G_OBEX_HDR_INVALID); @@ -2100,9 +2163,12 @@ static void test_conn_put_req(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -2112,7 +2178,6 @@ static void test_conn_put_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) }, @@ -2126,11 +2191,11 @@ static void test_conn_put_rsp(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); @@ -2148,9 +2213,12 @@ static void test_conn_put_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -2160,7 +2228,6 @@ static void test_conn_get_wrg_rsp(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_rsp, sizeof(conn_rsp) }, @@ -2172,11 +2239,11 @@ static void test_conn_get_wrg_rsp(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_add_request_function(obex, G_OBEX_OP_CONNECT, handle_conn_rsp, &d); @@ -2191,10 +2258,12 @@ static void test_conn_get_wrg_rsp(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - if (!d.io_completed) - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -2220,7 +2289,6 @@ static void test_conn_put_req_seq(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req, sizeof(conn_req) } , @@ -2236,11 +2304,11 @@ static void test_conn_put_req_seq(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_put_req_seq, &d, &d.err, G_OBEX_HDR_INVALID); @@ -2252,9 +2320,12 @@ static void test_conn_put_req_seq(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); @@ -2280,7 +2351,6 @@ static void test_conn_put_req_seq_srm(void) { GIOChannel *io; GIOCondition cond; - guint io_id, timer_id; GObex *obex; struct test_data d = { 0, NULL, { { conn_req_srm, sizeof(conn_req_srm) } , @@ -2296,11 +2366,11 @@ static void test_conn_put_req_seq_srm(void) d.obex = obex; cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL; - io_id = g_io_add_watch(io, cond, test_io_cb, &d); + d.io_id = g_io_add_watch(io, cond, test_io_cb, &d); d.mainloop = g_main_loop_new(NULL, FALSE); - timer_id = g_timeout_add_seconds(1, test_timeout, &d); + d.timer_id = g_timeout_add_seconds(1, test_timeout, &d); g_obex_connect(obex, conn_complete_put_req_seq_srm, &d, &d.err, G_OBEX_HDR_SRM, G_OBEX_SRM_INDICATE, @@ -2313,9 +2383,12 @@ static void test_conn_put_req_seq_srm(void) g_main_loop_unref(d.mainloop); - g_source_remove(timer_id); + if (d.timer_id > 0) + g_source_remove(d.timer_id); + if (d.io_id > 0) + g_source_remove(d.io_id); + g_io_channel_unref(io); - g_source_remove(io_id); g_obex_unref(obex); g_assert_no_error(d.err); |