Message ID | 20170823162004.27337-22-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
On 08/23/2017 01:19 PM, Marc-André Lureau wrote: > Use the one from the source with casting, like any other glib source. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > contrib/vhost-user-scsi/vhost-user-scsi.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c > index 795799ec14..102d910e8f 100644 > --- a/contrib/vhost-user-scsi/vhost-user-scsi.c > +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c > @@ -81,7 +81,6 @@ typedef struct vus_gsrc { > GSource parent; > VusDev *vdev_scsi; > GPollFD gfd; > - vu_watch_cb vu_cb; > } vus_gsrc_t; > > static gint vus_fdmap_compare(gconstpointer a, gconstpointer b) > @@ -112,18 +111,13 @@ static gboolean vus_gsrc_dispatch(GSource *src, GSourceFunc cb, gpointer data) > vus_gsrc_t *vus_src = (vus_gsrc_t *)src; > > assert(vus_src); > - assert(!(vus_src->vu_cb && cb)); > > vdev_scsi = vus_src->vdev_scsi; > > assert(vdev_scsi); > > - if (cb) { > - return cb(data); > - } > - if (vus_src->vu_cb) { > - vus_src->vu_cb(&vdev_scsi->vu_dev, vus_src->gfd.revents, data); > - } > + ((vu_watch_cb)cb) (&vdev_scsi->vu_dev, vus_src->gfd.revents, data); dropping the space between func/args: Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > + > return G_SOURCE_CONTINUE; > } > > @@ -146,12 +140,12 @@ static void vus_gsrc_new(VusDev *vdev_scsi, int fd, GIOCondition cond, > assert(vu_cb); > > vus_gsrc = g_source_new(&vus_gsrc_funcs, sizeof(vus_gsrc_t)); > + g_source_set_callback(vus_gsrc, (GSourceFunc) vu_cb, data, NULL); > vus_src = (vus_gsrc_t *)vus_gsrc; > > vus_src->vdev_scsi = vdev_scsi; > vus_src->gfd.fd = fd; > vus_src->gfd.events = cond; > - vus_src->vu_cb = vu_cb; > > g_source_add_poll(vus_gsrc, &vus_src->gfd); > id = g_source_attach(vus_gsrc, NULL); >
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c index 795799ec14..102d910e8f 100644 --- a/contrib/vhost-user-scsi/vhost-user-scsi.c +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c @@ -81,7 +81,6 @@ typedef struct vus_gsrc { GSource parent; VusDev *vdev_scsi; GPollFD gfd; - vu_watch_cb vu_cb; } vus_gsrc_t; static gint vus_fdmap_compare(gconstpointer a, gconstpointer b) @@ -112,18 +111,13 @@ static gboolean vus_gsrc_dispatch(GSource *src, GSourceFunc cb, gpointer data) vus_gsrc_t *vus_src = (vus_gsrc_t *)src; assert(vus_src); - assert(!(vus_src->vu_cb && cb)); vdev_scsi = vus_src->vdev_scsi; assert(vdev_scsi); - if (cb) { - return cb(data); - } - if (vus_src->vu_cb) { - vus_src->vu_cb(&vdev_scsi->vu_dev, vus_src->gfd.revents, data); - } + ((vu_watch_cb)cb) (&vdev_scsi->vu_dev, vus_src->gfd.revents, data); + return G_SOURCE_CONTINUE; } @@ -146,12 +140,12 @@ static void vus_gsrc_new(VusDev *vdev_scsi, int fd, GIOCondition cond, assert(vu_cb); vus_gsrc = g_source_new(&vus_gsrc_funcs, sizeof(vus_gsrc_t)); + g_source_set_callback(vus_gsrc, (GSourceFunc) vu_cb, data, NULL); vus_src = (vus_gsrc_t *)vus_gsrc; vus_src->vdev_scsi = vdev_scsi; vus_src->gfd.fd = fd; vus_src->gfd.events = cond; - vus_src->vu_cb = vu_cb; g_source_add_poll(vus_gsrc, &vus_src->gfd); id = g_source_attach(vus_gsrc, NULL);
Use the one from the source with casting, like any other glib source. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- contrib/vhost-user-scsi/vhost-user-scsi.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)