]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user_instance: just return when character device is not opened
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 14 Nov 2020 08:28:09 +0000 (17:28 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Sun, 15 Nov 2020 00:19:56 +0000 (09:19 +0900)
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 <o-takashi@sakamocchi.jp>
src/timer/user-instance.c

index 352a595ac1ea1cc7e4e18daca5f6e52ea62998e8..7707937ee25f0881fc5654e99db7a4cdcbc642a4 100644 (file)
@@ -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));