From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4Zod-00024y-Tl for qemu-devel@nongnu.org; Thu, 03 Dec 2015 14:45:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4Zoc-000187-P8 for qemu-devel@nongnu.org; Thu, 03 Dec 2015 14:45:19 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 3 Dec 2015 20:45:08 +0100 Message-Id: <1449171909-22018-4-git-send-email-afaerber@suse.de> In-Reply-To: <1449171909-22018-1-git-send-email-afaerber@suse.de> References: <1449171909-22018-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 3/4] tests: Use proper functions types instead of void (*fn) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: John Snow , Markus Armbruster , "open list:IDE" , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Markus Armbruster We have several function parameters declared as void (*fn). This is just a stupid way to write void *, and the only purpose writing it like that could serve is obscuring the sin of bypassing the type system without need. The original sin is commit 49ee359: its qtest_add_func() is a wrapper for g_test_add_func(). Fix the parameter type to match g_test_add_func()'s. This uncovers type errors in ide-test.c; fix them. Commit 7949c0e faithfully repeated the sin for qtest_add_data_func(). Fix it the same way, along with a harmless type error uncovered in vhost-user-test.c. Commit 063c23d repeated it for qtest_add_abrt_handler(). The screwy parameter gets assigned to GHook member func, so change its type to match. Requires wrapping kill_qemu() to keep the type checker happy. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Andreas F=C3=A4rber --- tests/ide-test.c | 4 ++-- tests/libqtest.c | 13 +++++++++---- tests/libqtest.h | 6 +++--- tests/vhost-user-test.c | 3 ++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/ide-test.c b/tests/ide-test.c index c3aacd2..b864701 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -593,12 +593,12 @@ static void test_flush_nodev(void) ide_test_quit(); } =20 -static void test_pci_retry_flush(const char *machine) +static void test_pci_retry_flush(void) { test_retry_flush("pc"); } =20 -static void test_isa_retry_flush(const char *machine) +static void test_isa_retry_flush(void) { test_retry_flush("isapc"); } diff --git a/tests/libqtest.c b/tests/libqtest.c index 9753161..c52ceb2 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -110,6 +110,11 @@ static void kill_qemu(QTestState *s) } } =20 +static void kill_qemu_hook_func(void *s) +{ + kill_qemu(s); +} + static void sigabrt_handler(int signo) { g_hook_list_invoke(&abrt_hooks, FALSE); @@ -133,7 +138,7 @@ static void cleanup_sigabrt_handler(void) sigaction(SIGABRT, &sigact_old, NULL); } =20 -void qtest_add_abrt_handler(void (*fn), const void *data) +void qtest_add_abrt_handler(GHookFunc fn, const void *data) { GHook *hook; =20 @@ -170,7 +175,7 @@ QTestState *qtest_init(const char *extra_args) sock =3D init_socket(socket_path); qmpsock =3D init_socket(qmp_socket_path); =20 - qtest_add_abrt_handler(kill_qemu, s); + qtest_add_abrt_handler(kill_qemu_hook_func, s); =20 s->qemu_pid =3D fork(); if (s->qemu_pid =3D=3D 0) { @@ -755,14 +760,14 @@ void qtest_memread(QTestState *s, uint64_t addr, vo= id *data, size_t size) g_strfreev(args); } =20 -void qtest_add_func(const char *str, void (*fn)) +void qtest_add_func(const char *str, GTestFunc fn) { gchar *path =3D g_strdup_printf("/%s/%s", qtest_get_arch(), str); g_test_add_func(path, fn); g_free(path); } =20 -void qtest_add_data_func(const char *str, const void *data, void (*fn)) +void qtest_add_data_func(const char *str, const void *data, GTestDataFun= c fn) { gchar *path =3D g_strdup_printf("/%s/%s", qtest_get_arch(), str); g_test_add_data_func(path, data, fn); diff --git a/tests/libqtest.h b/tests/libqtest.h index df08745..d11b5a4 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -416,7 +416,7 @@ const char *qtest_get_arch(void); * The path is prefixed with the architecture under test, as * returned by qtest_get_arch(). */ -void qtest_add_func(const char *str, void (*fn)); +void qtest_add_func(const char *str, GTestFunc fn); =20 /** * qtest_add_data_func: @@ -428,7 +428,7 @@ void qtest_add_func(const char *str, void (*fn)); * The path is prefixed with the architecture under test, as * returned by qtest_get_arch(). */ -void qtest_add_data_func(const char *str, const void *data, void (*fn)); +void qtest_add_data_func(const char *str, const void *data, GTestDataFun= c fn); =20 /** * qtest_add: @@ -450,7 +450,7 @@ void qtest_add_data_func(const char *str, const void = *data, void (*fn)); g_free(path); \ } while (0) =20 -void qtest_add_abrt_handler(void (*fn), const void *data); +void qtest_add_abrt_handler(GHookFunc fn, const void *data); =20 /** * qtest_start: diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 29de739..991fd85 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -173,8 +173,9 @@ static void wait_for_fds(TestServer *s) g_mutex_unlock(&s->data_mutex); } =20 -static void read_guest_mem(TestServer *s) +static void read_guest_mem(const void *data) { + TestServer *s =3D (void *)data; uint32_t *guest_mem; int i, j; size_t size; --=20 2.6.2