From 4c0d64dd1088c1c365143b430017317faaa133e1 Mon Sep 17 00:00:00 2001 From: Camilo Celis Guzman Date: Mon, 18 Apr 2022 18:53:45 +0900 Subject: [PATCH] gstglmixerbin: minor refactor of _find_element_pad_template As suggested by @slomo, make the loop more readable and prevent returning a garbage value to the caller from the previous implementation. Part-of: --- .../gst-plugins-base/ext/gl/gstglmixerbin.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-base/ext/gl/gstglmixerbin.c b/subprojects/gst-plugins-base/ext/gl/gstglmixerbin.c index 591e65932b..4e8d045e57 100644 --- a/subprojects/gst-plugins-base/ext/gl/gstglmixerbin.c +++ b/subprojects/gst-plugins-base/ext/gl/gstglmixerbin.c @@ -375,23 +375,20 @@ _find_element_pad_template (GstElement * element, { GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); GList *templ_list = gst_element_class_get_pad_template_list (klass); - GstPadTemplate *templ; /* find suitable template */ while (templ_list) { - templ = (GstPadTemplate *) templ_list->data; + GstPadTemplate *templ = (GstPadTemplate *) templ_list->data; - if (GST_PAD_TEMPLATE_DIRECTION (templ) != direction - || GST_PAD_TEMPLATE_PRESENCE (templ) != presence) { - templ_list = templ_list->next; - templ = NULL; - continue; + if (GST_PAD_TEMPLATE_DIRECTION (templ) == direction + && GST_PAD_TEMPLATE_PRESENCE (templ) == presence) { + return templ; } - break; + templ_list = templ_list->next; } - return templ; + return NULL; } static gboolean