From: Jan Alexander Steffens (heftig) Date: Tue, 27 Mar 2018 08:15:46 +0000 (+0200) Subject: gstinfo: Simplify gst_debug_reset_threshold() implementation X-Git-Tag: 1.16.2~420 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4ff06986442fe50f424161220ccb31db758b797;p=platform%2Fupstream%2Fgstreamer.git gstinfo: Simplify gst_debug_reset_threshold() implementation 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 --- diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 63857ce..b1d86f0 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -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