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.
This commit is contained in:
Tim-Philipp Müller 2016-01-21 15:45:30 +00:00
parent a72368ebb3
commit 05a9655523

View file

@ -334,8 +334,8 @@ gst_device_reconfigure_element (GstDevice * device, GstElement * element)
/** /**
* gst_device_has_classesv: * gst_device_has_classesv:
* @device: a #GstDevice * @device: a #GstDevice
* @classes: (array zero-terminated=1): a %NULL terminated array of classes to match, only match if all * @classes: (array zero-terminated=1): a %NULL terminated array of classes
* classes are matched * to match, only match if all classes are matched
* *
* Check if @factory matches all of the given classes * Check if @factory matches all of the given classes
* *
@ -352,20 +352,21 @@ gst_device_has_classesv (GstDevice * device, gchar ** classes)
return TRUE; return TRUE;
for (; classes[0]; classes++) { for (; classes[0]; classes++) {
const gchar *klass = classes[0];
const gchar *found; const gchar *found;
guint len; guint len;
if (classes[0] == '\0') if (*klass == '\0')
continue; continue;
found = strstr (device->priv->device_class, classes[0]); found = strstr (device->priv->device_class, klass);
if (!found) if (!found)
return FALSE; return FALSE;
if (found != device->priv->device_class && *(found - 1) != '/') if (found != device->priv->device_class && *(found - 1) != '/')
return FALSE; return FALSE;
len = strlen (classes[0]); len = strlen (klass);
if (found[len] != 0 && found[len] != '/') if (found[len] != 0 && found[len] != '/')
return FALSE; return FALSE;
} }
@ -376,7 +377,7 @@ gst_device_has_classesv (GstDevice * device, gchar ** classes)
/** /**
* gst_device_has_classes: * gst_device_has_classes:
* @device: a #GstDevice * @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 * all classes are matched
* *
* Check if @device matches all of the given classes * Check if @device matches all of the given classes