From: Takashi Sakamoto Date: Sat, 14 Nov 2020 08:28:09 +0000 (+0900) Subject: timer: user_instance: just return when character device is not opened X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=e0b44801bad80d0d753580e4810914d7fed5bd7e;p=alsa-gobject.git timer: user_instance: just return when character device is not opened It's programming mistake when operating without opening character device. This commit uses GLib macro just return in the case with warnings. Signed-off-by: Takashi Sakamoto --- diff --git a/src/timer/user-instance.c b/src/timer/user-instance.c index 352a595..7707937 100644 --- a/src/timer/user-instance.c +++ b/src/timer/user-instance.c @@ -179,15 +179,11 @@ void alsatimer_user_instance_get_protocol_version(ALSATimerUserInstance *self, g_return_if_fail(ALSATIMER_IS_USER_INSTANCE(self)); priv = alsatimer_user_instance_get_instance_private(self); + g_return_if_fail(priv->fd >= 0); g_return_if_fail(proto_ver_triplet != NULL); g_return_if_fail(error == NULL || *error == NULL); - if (priv->fd < 0) { - generate_error(error, ENXIO); - return; - } - *proto_ver_triplet = (const guint16 *)priv->proto_ver_triplet; } @@ -490,15 +486,11 @@ void alsatimer_user_instance_create_source(ALSATimerUserInstance *self, g_return_if_fail(ALSATIMER_IS_USER_INSTANCE(self)); priv = alsatimer_user_instance_get_instance_private(self); + g_return_if_fail(priv->fd >= 0); g_return_if_fail(gsrc != NULL); g_return_if_fail(error == NULL || *error == NULL); - if (priv->fd < 0) { - generate_error(error, ENXIO); - return; - } - buf = g_malloc0(page_size); *gsrc = g_source_new(&funcs, sizeof(TimerUserInstanceSource));