From 05a96555233649eb132c366ae54ee330d267ddd9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 21 Jan 2016 15:45:30 +0000 Subject: [PATCH] device: fix comparison in _has_classesv() We're comparing a pointer type with '\0' here, which probably isn't right, and the loop condition made sure that classes[0] is != NULL already, so it's pointless. Was probaby meant to check if the string pointed to is not empty, so make it do that instead. --- gst/gstdevice.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gst/gstdevice.c b/gst/gstdevice.c index ee92619..55f5604 100644 --- a/gst/gstdevice.c +++ b/gst/gstdevice.c @@ -334,8 +334,8 @@ gst_device_reconfigure_element (GstDevice * device, GstElement * element) /** * gst_device_has_classesv: * @device: a #GstDevice - * @classes: (array zero-terminated=1): a %NULL terminated array of classes to match, only match if all - * classes are matched + * @classes: (array zero-terminated=1): a %NULL terminated array of classes + * to match, only match if all classes are matched * * Check if @factory matches all of the given classes * @@ -352,20 +352,21 @@ gst_device_has_classesv (GstDevice * device, gchar ** classes) return TRUE; for (; classes[0]; classes++) { + const gchar *klass = classes[0]; const gchar *found; guint len; - if (classes[0] == '\0') + if (*klass == '\0') continue; - found = strstr (device->priv->device_class, classes[0]); + found = strstr (device->priv->device_class, klass); if (!found) return FALSE; if (found != device->priv->device_class && *(found - 1) != '/') return FALSE; - len = strlen (classes[0]); + len = strlen (klass); if (found[len] != 0 && found[len] != '/') return FALSE; } @@ -376,7 +377,7 @@ gst_device_has_classesv (GstDevice * device, gchar ** classes) /** * gst_device_has_classes: * @device: a #GstDevice - * @classes: a "/" separate list of device classes to match, only match if + * @classes: a "/"-separated list of device classes to match, only match if * all classes are matched * * Check if @device matches all of the given classes -- 2.7.4