tests MAINTENANCE avoid function pointer cast
diff --git a/tests/utests/basic/test_inout.c b/tests/utests/basic/test_inout.c
index f0f7968..d2455fd 100644
--- a/tests/utests/basic/test_inout.c
+++ b/tests/utests/basic/test_inout.c
@@ -281,6 +281,18 @@
ly_out_free(out, NULL, 1);
}
+static ssize_t
+write_clb(void *user_data, const void *buf, size_t count)
+{
+ return write((uintptr_t)user_data, buf, count);
+}
+
+void
+close_clb(void *arg)
+{
+ close((uintptr_t)arg);
+}
+
static void
test_output_clb(void **UNUSED(state))
{
@@ -293,16 +305,16 @@
assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
/* manipulate with the handler */
- assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void *)(intptr_t)fd1, &out));
+ assert_int_equal(LY_SUCCESS, ly_out_new_clb(write_clb, (void *)(intptr_t)fd1, &out));
assert_int_equal(LY_OUT_CALLBACK, ly_out_type(out));
assert_ptr_equal(fd1, ly_out_clb_arg(out, (void *)(intptr_t)fd2));
assert_ptr_equal(fd2, ly_out_clb_arg(out, NULL));
assert_ptr_equal(fd2, ly_out_clb_arg(out, (void *)(intptr_t)fd1));
- assert_ptr_equal(write, ly_out_clb(out, (void *)write));
+ assert_ptr_equal(write_clb, ly_out_clb(out, write_clb));
ly_out_free(out, NULL, 0);
assert_int_equal(0, close(fd2));
- assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void *)(intptr_t)fd1, &out));
- ly_out_free(out, (void *)close, 0);
+ assert_int_equal(LY_SUCCESS, ly_out_new_clb(write_clb, (void *)(intptr_t)fd1, &out));
+ ly_out_free(out, close_clb, 0);
/* writing data */
assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
@@ -310,14 +322,14 @@
/* truncate file to start with no data */
assert_int_equal(0, ftruncate(fd1, 0));
- assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void *)(intptr_t)fd1, &out));
+ assert_int_equal(LY_SUCCESS, ly_out_new_clb(write_clb, (void *)(intptr_t)fd1, &out));
assert_int_equal(LY_SUCCESS, ly_print(out, "test %s", "print"));
assert_int_equal(10, ly_out_printed(out));
assert_int_equal(10, read(fd2, buf, 30));
assert_string_equal("test print", buf);
close(fd2);
- ly_out_free(out, (void *)close, 0);
+ ly_out_free(out, close_clb, 0);
}
int