]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
rawmidi: query: simplify count check
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 16 Nov 2020 02:45:41 +0000 (11:45 +0900)
Usually, when creating list of something, count decision at first, then
generate items of the list. At last, the number of items is checked as
the same as the count. However, it's unlikely to have different number
of items.

This commit simplifies the count check.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/rawmidi/query.c

index 657594da5222b2518a4e1f9666258eba77ba03af..4327cb7e2806e0caf0d83af3d1d3952d1ab13bf1 100644 (file)
@@ -192,12 +192,9 @@ void alsarawmidi_get_device_id_list(guint card_id, guint **entries,
             udev_device_unref(dev);
         }
     }
-    if (index != count) {
-        g_warn_if_reached();
-        g_free(*entries);
-        *entries = NULL;
-        goto end;
-    }
+
+    g_warn_if_fail(index == count);
+
     *entry_count = count;
 
     qsort(*entries, count, sizeof(guint), compare_guint);