device: fix comparison in _has_classesv()
authorTim-Philipp Müller <tim@centricular.com>
Thu, 21 Jan 2016 15:45:30 +0000 (15:45 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 21 Jan 2016 15:45:30 +0000 (15:45 +0000)
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

index ee92619..55f5604 100644 (file)
@@ -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