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

@ -37,7 +37,7 @@ static inline void push_item(struct spa_pod_builder *b, const struct spa_dict_it
const char *str;
spa_pod_builder_string(b, item->key);
str = item->value;
if (strstr(str, "pointer:") == str)
if (spa_strstartswith(str, "pointer:"))
str = "";
spa_pod_builder_string(b, str);
}
@ -50,7 +50,7 @@ static inline int parse_item(struct spa_pod_parser *prs, struct spa_dict_item *i
SPA_POD_String(&item->value),
NULL)) < 0)
return res;
if (strstr(item->value, "pointer:") == item->value)
if (spa_strstartswith(item->value, "pointer:"))
item->value = "";
return 0;
}

View file

@ -38,7 +38,7 @@ static inline void push_item(struct spa_pod_builder *b, const struct spa_dict_it
const char *str;
spa_pod_builder_string(b, item->key);
str = item->value;
if (strstr(str, "pointer:") == str)
if (spa_strstartswith(str, "pointer:"))
str = "";
spa_pod_builder_string(b, str);
}
@ -65,7 +65,7 @@ static inline int parse_item(struct spa_pod_parser *prs, struct spa_dict_item *i
SPA_POD_String(&item->value),
NULL)) < 0)
return res;
if (strstr(item->value, "pointer:") == item->value)
if (spa_strstartswith(item->value, "pointer:"))
item->value = "";
return 0;
}

View file

@ -132,7 +132,7 @@ static inline void push_item(struct spa_pod_builder *b, const struct spa_dict_it
const char *str;
spa_pod_builder_string(b, item->key);
str = item->value;
if (strstr(str, "pointer:") == str)
if (spa_strstartswith(str, "pointer:"))
str = "";
spa_pod_builder_string(b, str);
}
@ -159,7 +159,7 @@ static inline int parse_item(struct spa_pod_parser *prs, struct spa_dict_item *i
SPA_POD_String(&item->value),
NULL)) < 0)
return res;
if (strstr(item->value, "pointer:") == item->value)
if (spa_strstartswith(item->value, "pointer:"))
item->value = "";
return 0;
}

View file

@ -63,9 +63,9 @@ static int key_from_name(const char *name, char *key, size_t maxlen)
{
const char *media_class, *select, *str;
if (strstr(name, "sink-input-") == name)
if (spa_strstartswith(name, "sink-input-"))
media_class = "Output/Audio";
else if (strstr(name, "source-output-") == name)
else if (spa_strstartswith(name, "source-output-"))
media_class = "Input/Audio";
else
return -1;
@ -100,9 +100,9 @@ static int key_to_name(const char *key, char *name, size_t maxlen)
{
const char *type, *select, *str;
if (strstr(key, "restore.stream.Output/Audio.") == key)
if (spa_strstartswith(key, "restore.stream.Output/Audio."))
type = "sink-input";
else if (strstr(key, "restore.stream.Input/Audio.") == key)
else if (spa_strstartswith(key, "restore.stream.Input/Audio."))
type = "source-output";
else
type = "stream";

View file

@ -634,7 +634,7 @@ static struct server *create_server(struct impl *impl, const char *address)
spa_list_init(&server->client_list);
spa_list_append(&impl->server_list, &server->link);
if (strstr(address, "tcp:") == address) {
if (spa_strstartswith(address, "tcp:")) {
fd = make_inet_socket(server, address+4);
} else {
fd = -EINVAL;