tree-wide: replace strstr(a, b) == a with spa_strstartswith()

spa_strstartswith() is more immediately understandable.

Coccinelle spatch file:
	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) != E1
	+ !spa_strstartswith(E1, E2)

	@@
	expression E1, E2;
	@@
	- strstr(E1, E2) == E1
	+ spa_strstartswith(E1, E2)

Applied to the tree except for alsa/acp/compat.h because it looks like
that header is still mostly as-is from PA.
This commit is contained in:
Peter Hutterer 2021-08-02 14:05:45 +10:00 committed by Wim Taymans
parent 60c510d766
commit 51a177eb6d
20 changed files with 48 additions and 48 deletions

View file

@ -244,7 +244,7 @@ static int metadata_property(void *object, uint32_t subject,
pw_properties_clear(impl->props);
changed = 1;
}
else if (strstr(key, PREFIX) == key) {
else if (spa_strstartswith(key, PREFIX)) {
changed += pw_properties_set(impl->props, key, value);
}
}
@ -472,12 +472,12 @@ static void session_create(void *data, struct sm_object *object)
(media_class = pw_properties_get(object->props, PW_KEY_MEDIA_CLASS)) == NULL)
return;
if (strstr(media_class, "Stream/") == media_class) {
if (spa_strstartswith(media_class, "Stream/")) {
media_class += strlen("Stream/");
pw_log_debug(NAME " %p: add stream '%d' %s", impl, object->id, media_class);
} else if (strstr(media_class, "Audio/") == media_class &&
((routes = pw_properties_get(object->props, "device.routes")) == NULL ||
atoi(routes) == 0)) {
} else if (spa_strstartswith(media_class, "Audio/") &&
((routes = pw_properties_get(object->props, "device.routes")) == NULL ||
atoi(routes) == 0)) {
pw_log_debug(NAME " %p: add node '%d' %s", impl, object->id, media_class);
} else {
return;