From de7218c1a16ee9959865e84ad6898695765669f6 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Fri, 13 Nov 2020 16:26:26 +0900 Subject: [PATCH] ctl: card: just return when character device is not opened 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 --- src/ctl/card.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/ctl/card.c b/src/ctl/card.c index 03fcae6..f6fccb6 100644 --- a/src/ctl/card.c +++ b/src/ctl/card.c @@ -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)); -- 2.47.3