gstinfo: Simplify gst_debug_reset_threshold() implementation
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Tue, 27 Mar 2018 08:15:46 +0000 (10:15 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 5 Apr 2018 09:52:13 +0000 (10:52 +0100)
Replace the while+goto with a for+break and check walk to determine
whether we had a match. Move up the unlock to keep the locked section as
small as possible.

https://bugzilla.gnome.org/show_bug.cgi?id=794717

gst/gstinfo.c

index 63857ce..b1d86f0 100644 (file)
@@ -1598,18 +1598,16 @@ gst_debug_reset_threshold (gpointer category, gpointer unused)
   GSList *walk;
 
   g_mutex_lock (&__level_name_mutex);
-  walk = __level_name;
-  while (walk) {
-    LevelNameEntry *entry = walk->data;
 
-    walk = g_slist_next (walk);
-    if (gst_debug_apply_entry (cat, entry))
-      goto exit;
+  for (walk = __level_name; walk != NULL; walk = walk->next) {
+    if (gst_debug_apply_entry (cat, walk->data))
+      break;
   }
-  gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
 
-exit:
   g_mutex_unlock (&__level_name_mutex);
+
+  if (walk == NULL)
+    gst_debug_category_set_threshold (cat, gst_debug_get_default_threshold ());
 }
 
 static void