From 98d2c12ac2f8dc7e92790e927f472e26459d3852 Mon Sep 17 00:00:00 2001 From: Timo Wischer Date: Thu, 5 Oct 2017 16:25:23 +0200 Subject: [PATCH] ctl: ext: Fail with error code if snd_ctl_ext_callback::read_event() callback is not defined The snd_ctl_ext_callback::read_event() callback is only optional if no poll descriptor was given via snd_ctl_ext_t::poll_fd or snd_ctl_ext_callback::snd_ctl_ext_poll_descriptors(). If a poll descriptor is given the snd_ctl_ext_callback::read_event() callback has also to be defined because there is no minigful default behavior. This callback will be called when ever the poll() on the file descriptor indicates that there is an event pending. Therefore returning a 0 which indicates that there is no event makes no sense. Signed-off-by: Timo Wischer Signed-off-by: Takashi Iwai --- src/control/control_ext.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/control/control_ext.c b/src/control/control_ext.c index 56552fa1..d7de8e84 100644 --- a/src/control/control_ext.c +++ b/src/control/control_ext.c @@ -415,8 +415,12 @@ static int snd_ctl_ext_read(snd_ctl_t *handle, snd_ctl_event_t *event) { snd_ctl_ext_t *ext = handle->private_data; - memset(event, 0, sizeof(*event)); - return ext->callback->read_event(ext, &event->data.elem.id, &event->data.elem.mask); + if (ext->callback->read_event) { + memset(event, 0, sizeof(*event)); + return ext->callback->read_event(ext, &event->data.elem.id, &event->data.elem.mask); + } + + return -EINVAL; } static int snd_ctl_ext_poll_descriptors_count(snd_ctl_t *handle) -- 2.47.1