aboutsummaryrefslogtreecommitdiff
path: root/contrib/vhost-user-scsi/vhost-user-scsi.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-08-17 19:59:15 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-10-10 23:31:09 +0200
commit3e7bd3ad47b86d0ec4d85c0ae839bdd9f49dad46 (patch)
tree0822e975d2e98fb71547432f0a13883f60be7b4d /contrib/vhost-user-scsi/vhost-user-scsi.c
parent49a48824384cca914e20b30de3d2a99916d8cf02 (diff)
vhost-user-scsi: drop extra callback pointer
Use the one from the source with casting, like any other glib source. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'contrib/vhost-user-scsi/vhost-user-scsi.c')
-rw-r--r--contrib/vhost-user-scsi/vhost-user-scsi.c12
1 files 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 cfac1ce1fe..0e6784187c 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;
}
@@ -147,12 +141,12 @@ static void vus_gsrc_new(VusDev *vdev_scsi, int fd, GIOCondition cond,
assert(!(vu_cb && gsrc_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);
g_source_set_callback(vus_gsrc, gsrc_cb, data, NULL);