From e0b44801bad80d0d753580e4810914d7fed5bd7e Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sat, 14 Nov 2020 17:28:09 +0900 Subject: [PATCH] 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 --- src/timer/user-instance.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) 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)); -- 2.47.3