Received: from eggs.gnu.org ([2001:4830:134:3::10]:41451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3RVP-0004Y6-6P for qemu-devel@nongnu.org; Mon, 30 Nov 2015 11:40:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3RVK-0005qL-Vs for qemu-devel@nongnu.org; Mon, 30 Nov 2015 11:40:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3RVK-0005qF-Qh for qemu-devel@nongnu.org; Mon, 30 Nov 2015 11:40:42 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 1B77568E3D for ; Mon, 30 Nov 2015 16:40:42 +0000 (UTC) From: Markus Armbruster References: <1448882220-24744-1-git-send-email-marcandre.lureau@redhat.com> <1448882220-24744-4-git-send-email-marcandre.lureau@redhat.com> <20151130150713-mutt-send-email-mst@redhat.com> Date: Mon, 30 Nov 2015 17:40:39 +0100 In-Reply-To: <20151130150713-mutt-send-email-mst@redhat.com> (Michael S. Tsirkin's message of "Mon, 30 Nov 2015 15:08:00 +0200") Message-ID: <87d1ur4f08.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 3/3] vhost-user-test: fix crash with glib < 2.36 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org "Michael S. Tsirkin" writes: > On Mon, Nov 30, 2015 at 12:17:00PM +0100, marcandre.lureau@redhat.com wro= te: >> From: Marc-Andr=C3=A9 Lureau >>=20 >> The prepare callback needs to be implemented with glib < 2.36. >>=20 >> Signed-off-by: Marc-Andr=C3=A9 Lureau >> --- >> tests/vhost-user-test.c | 17 +++++++++++++---- >> 1 file changed, 13 insertions(+), 4 deletions(-) >>=20 >> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c >> index 29205ed..27dedeb 100644 >> --- a/tests/vhost-user-test.c >> +++ b/tests/vhost-user-test.c >> @@ -506,11 +506,20 @@ test_migrate_source_check(GSource *source) >> return FALSE; >> } >>=20=20 >> +#if !GLIB_CHECK_VERSION(2,36,0) >> +static gboolean >> +test_migrate_source_prepare(GSource *source, gint *timeout) >> +{ >> + *timeout =3D -1; >> + return FALSE; >> +} >> +#endif >> + >> GSourceFuncs test_migrate_source_funcs =3D { >> - NULL, >> - test_migrate_source_check, >> - NULL, >> - NULL >> +#if !GLIB_CHECK_VERSION(2,36,0) >> + .prepare =3D test_migrate_source_prepare, >> +#endif >> + .check =3D test_migrate_source_check, >> }; >>=20=20 >> static void test_migrate(void) > > I don't see why do we need the ifdefs, we can use the > same code for all versions. > I queued a patch that does exactly that. The ifdefs serve as a marker that lets us drop unnecessary code when our required version of GLib reaches 2.36. A comment might do, too, but it should probably contain GLIB_CHECK_VERSION() to be visible in grep.