]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: card: just return when character device is not opened
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 13 Nov 2020 07:26:26 +0000 (16:26 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Fri, 13 Nov 2020 23:30:49 +0000 (08:30 +0900)
It's programming error 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/ctl/card.c

index 03fcae66b71702a167e7e9971b0c119dc26dd6ad..f6fccb6fef2255ddc3c81a4f4ba8ea2ccd389dd2 100644 (file)
@@ -234,15 +234,11 @@ void alsactl_card_get_protocol_version(ALSACtlCard *self,
 
     g_return_if_fail(ALSACTL_IS_CARD(self));
     priv = alsactl_card_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;
 }
 
@@ -993,15 +989,11 @@ void alsactl_card_create_source(ALSACtlCard *self, GSource **gsrc,
 
     g_return_if_fail(ALSACTL_IS_CARD(self));
     priv = alsactl_card_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(CtlCardSource));