diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index f2c17e5dc..e243259ba 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -2534,7 +2534,7 @@ static void registry_event_global(void *data, uint32_t id, node_id = atoi(str); if ((str = spa_dict_lookup(props, PW_KEY_PORT_EXTRA)) != NULL && - strstr(str, "jack:flags:") == str) + spa_strstartswith(str, "jack:flags:")) flags = atoi(str+11); if ((str = spa_dict_lookup(props, PW_KEY_PORT_NAME)) == NULL) diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 0c6da8a3e..9b94fcbd8 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -412,9 +412,9 @@ static const struct a2dp_codec *a2dp_endpoint_to_codec(const char *endpoint) const char *codec_name; int i; - if (strstr(endpoint, A2DP_SINK_ENDPOINT "/") == endpoint) + if (spa_strstartswith(endpoint, A2DP_SINK_ENDPOINT "/")) codec_name = endpoint + strlen(A2DP_SINK_ENDPOINT "/"); - else if (strstr(endpoint, A2DP_SOURCE_ENDPOINT "/") == endpoint) + else if (spa_strstartswith(endpoint, A2DP_SOURCE_ENDPOINT "/")) codec_name = endpoint + strlen(A2DP_SOURCE_ENDPOINT "/"); else return NULL; @@ -430,9 +430,9 @@ static const struct a2dp_codec *a2dp_endpoint_to_codec(const char *endpoint) static int a2dp_endpoint_to_profile(const char *endpoint) { - if (strstr(endpoint, A2DP_SINK_ENDPOINT "/") == endpoint) + if (spa_strstartswith(endpoint, A2DP_SINK_ENDPOINT "/")) return SPA_BT_PROFILE_A2DP_SOURCE; - else if (strstr(endpoint, A2DP_SOURCE_ENDPOINT "/") == endpoint) + else if (spa_strstartswith(endpoint, A2DP_SOURCE_ENDPOINT "/")) return SPA_BT_PROFILE_A2DP_SINK; else return SPA_BT_PROFILE_NULL; diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index ddd6d2630..5c20c6f1c 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -175,7 +175,7 @@ impl_cpu_get_vm_type(void *object) continue; for (j = 0; j < SPA_N_ELEMENTS(dmi_vendor_table); j++) { - if (strstr(s, dmi_vendor_table[j].vendor) == s) { + if (spa_strstartswith(s, dmi_vendor_table[j].vendor)) { spa_log_debug(impl->log, "Virtualization %s found in DMI (%s)", s, dmi_vendors[i]); impl->vm_type = dmi_vendor_table[j].id; diff --git a/src/examples/media-session/alsa-endpoint.c b/src/examples/media-session/alsa-endpoint.c index 757702fd2..015646fc3 100644 --- a/src/examples/media-session/alsa-endpoint.c +++ b/src/examples/media-session/alsa-endpoint.c @@ -679,7 +679,7 @@ handle_device(struct impl *impl, struct sm_object *obj) pw_log_debug(NAME" %p: device "PW_KEY_MEDIA_CLASS":%s api:%s", impl, media_class, str); - if (strstr(media_class, "Audio/") != media_class) + if (!spa_strstartswith(media_class, "Audio/")) return 0; if (!spa_streq(str, "alsa")) return 0; diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index 83bafa8d6..aea7f1043 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -321,9 +321,9 @@ static struct node *alsa_create_node(struct device *device, uint32_t id, priority -= atol(dev) * 16; priority -= atol(subdev); - if (strstr(profile, "analog-") == profile) + if (spa_strstartswith(profile, "analog-")) priority += 9; - else if (strstr(profile, "iec958-") == profile) + else if (spa_strstartswith(profile, "iec958-")) priority += 8; if (pw_properties_get(node->props, PW_KEY_PRIORITY_DRIVER) == NULL) { @@ -356,7 +356,7 @@ static struct node *alsa_create_node(struct device *device, uint32_t id, if ((devname = pw_properties_get(device->props, SPA_KEY_DEVICE_NAME)) == NULL) devname = "unnamed-device"; - if (strstr(devname, "alsa_card.") == devname) + if (spa_strstartswith(devname, "alsa_card.")) devname += 10; pw_properties_set(node->props, SPA_KEY_NODE_NAME, diff --git a/src/examples/media-session/bluez-endpoint.c b/src/examples/media-session/bluez-endpoint.c index d3acff22e..b82aa69de 100644 --- a/src/examples/media-session/bluez-endpoint.c +++ b/src/examples/media-session/bluez-endpoint.c @@ -616,7 +616,7 @@ handle_device(struct impl *impl, struct sm_object *obj) pw_log_debug(NAME" %p: device "PW_KEY_MEDIA_CLASS":%s api:%s", impl, media_class, str); - if (strstr(media_class, "Audio/") != media_class) + if (!spa_strstartswith(media_class, "Audio/")) return 0; if (!spa_streq(str, "bluez5")) return 0; diff --git a/src/examples/media-session/bluez-monitor.c b/src/examples/media-session/bluez-monitor.c index a0e83d3ca..c06ae7234 100644 --- a/src/examples/media-session/bluez-monitor.c +++ b/src/examples/media-session/bluez-monitor.c @@ -405,7 +405,7 @@ static int update_device_props(struct device *device) snprintf(temp, sizeof(temp), "%d", device->id); s = temp; } - if (strstr(s, "bluez_card.") == s) + if (spa_strstartswith(s, "bluez_card.")) s += strlen("bluez_card."); pw_properties_set(p, PW_KEY_DEVICE_NAME, diff --git a/src/examples/media-session/policy-ep.c b/src/examples/media-session/policy-ep.c index 82dba73b4..6bc48604d 100644 --- a/src/examples/media-session/policy-ep.c +++ b/src/examples/media-session/policy-ep.c @@ -130,14 +130,14 @@ handle_endpoint(struct impl *impl, struct sm_object *object) ep->enabled = true; spa_list_append(&impl->endpoint_list, &ep->link); - if (strstr(media_class, "Stream/") == media_class) { + if (spa_strstartswith(media_class, "Stream/")) { media_class += strlen("Stream/"); - if (strstr(media_class, "Output/") == media_class) { + if (spa_strstartswith(media_class, "Output/")) { direction = PW_DIRECTION_OUTPUT; media_class += strlen("Output/"); } - else if (strstr(media_class, "Input/") == media_class) { + else if (spa_strstartswith(media_class, "Input/")) { direction = PW_DIRECTION_INPUT; media_class += strlen("Input/"); } @@ -151,11 +151,11 @@ handle_endpoint(struct impl *impl, struct sm_object *object) } else { const char *media; - if (strstr(media_class, "Audio/") == media_class) { + if (spa_strstartswith(media_class, "Audio/")) { media_class += strlen("Audio/"); media = "Audio"; } - else if (strstr(media_class, "Video/") == media_class) { + else if (spa_strstartswith(media_class, "Video/")) { media_class += strlen("Video/"); media = "Video"; } diff --git a/src/examples/media-session/policy-node.c b/src/examples/media-session/policy-node.c index 1f6ba005f..97db04df5 100644 --- a/src/examples/media-session/policy-node.c +++ b/src/examples/media-session/policy-node.c @@ -294,21 +294,21 @@ handle_node(struct impl *impl, struct sm_object *object) if (role && spa_streq(role, "DSP")) node->active = node->configured = true; - if (strstr(media_class, "Stream/") == media_class) { + if (spa_strstartswith(media_class, "Stream/")) { media_class += strlen("Stream/"); - if (strstr(media_class, "Output/") == media_class) { + if (spa_strstartswith(media_class, "Output/")) { direction = PW_DIRECTION_OUTPUT; media_class += strlen("Output/"); } - else if (strstr(media_class, "Input/") == media_class) { + else if (spa_strstartswith(media_class, "Input/")) { direction = PW_DIRECTION_INPUT; media_class += strlen("Input/"); } else return 0; - if (strstr(media_class, "Video") == media_class) { + if (spa_strstartswith(media_class, "Video")) { if (direction == PW_DIRECTION_OUTPUT) { if ((str = pw_properties_get(object->props, PW_KEY_NODE_PLUGGED)) != NULL) node->plugged = pw_properties_parse_uint64(str); @@ -317,7 +317,7 @@ handle_node(struct impl *impl, struct sm_object *object) } node->active = node->configured = true; } - else if (strstr(media_class, "Unknown") == media_class) { + else if (spa_strstartswith(media_class, "Unknown")) { node->active = node->configured = true; } @@ -330,11 +330,11 @@ handle_node(struct impl *impl, struct sm_object *object) const char *media; bool virtual = false; - if (strstr(media_class, "Audio/") == media_class) { + if (spa_strstartswith(media_class, "Audio/")) { media_class += strlen("Audio/"); media = "Audio"; } - else if (strstr(media_class, "Video/") == media_class) { + else if (spa_strstartswith(media_class, "Video/")) { media_class += strlen("Video/"); media = "Video"; node->active = node->configured = true; diff --git a/src/examples/media-session/restore-stream.c b/src/examples/media-session/restore-stream.c index afa5b2fd9..b52823db4 100644 --- a/src/examples/media-session/restore-stream.c +++ b/src/examples/media-session/restore-stream.c @@ -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; diff --git a/src/examples/media-session/stream-endpoint.c b/src/examples/media-session/stream-endpoint.c index f7f695f25..2a7f52500 100644 --- a/src/examples/media-session/stream-endpoint.c +++ b/src/examples/media-session/stream-endpoint.c @@ -516,16 +516,16 @@ handle_node(struct impl *impl, struct sm_object *obj) if (media_class == NULL) return 0; - if (strstr(media_class, "Stream/") != media_class) + if (!spa_strstartswith(media_class, "Stream/")) return 0; media_class += strlen("Stream/"); - if (strstr(media_class, "Output/") == media_class) { + if (spa_strstartswith(media_class, "Output/")) { direction = PW_DIRECTION_OUTPUT; media_class += strlen("Output/"); } - else if (strstr(media_class, "Input/") == media_class) { + else if (spa_strstartswith(media_class, "Input/")) { direction = PW_DIRECTION_INPUT; media_class += strlen("Input/"); } diff --git a/src/examples/media-session/suspend-node.c b/src/examples/media-session/suspend-node.c index 81f8bb155..3c167a73d 100644 --- a/src/examples/media-session/suspend-node.c +++ b/src/examples/media-session/suspend-node.c @@ -178,8 +178,8 @@ handle_node(struct impl *impl, struct sm_object *object) if (media_class == NULL) return 0; - if (strstr(media_class, "Audio/") != media_class && - (strstr(media_class, "Video/") != media_class)) + if (!spa_strstartswith(media_class, "Audio/") && + (!spa_strstartswith(media_class, "Video/"))) return 0; node = sm_object_add_data(object, SESSION_KEY, sizeof(struct node)); diff --git a/src/examples/media-session/v4l2-endpoint.c b/src/examples/media-session/v4l2-endpoint.c index 558f33ee9..3184cdc4b 100644 --- a/src/examples/media-session/v4l2-endpoint.c +++ b/src/examples/media-session/v4l2-endpoint.c @@ -563,7 +563,7 @@ handle_device(struct impl *impl, struct sm_object *obj) pw_log_debug(NAME" %p: device "PW_KEY_MEDIA_CLASS":%s api:%s", impl, media_class, str); - if (strstr(media_class, "Video/") != media_class) + if (!spa_strstartswith(media_class, "Video/")) return 0; if (!spa_streq(str, "v4l2")) return 0; diff --git a/src/examples/media-session/v4l2-monitor.c b/src/examples/media-session/v4l2-monitor.c index 6de9b6142..b98274e9d 100644 --- a/src/examples/media-session/v4l2-monitor.c +++ b/src/examples/media-session/v4l2-monitor.c @@ -154,7 +154,7 @@ static struct node *v4l2_create_node(struct device *dev, uint32_t id, str = pw_properties_get(dev->props, SPA_KEY_DEVICE_ALIAS); if (str == NULL) str = "v4l2-device"; - if (strstr(str, "v4l2_device.") == str) + if (spa_strstartswith(str, "v4l2_device.")) str += 12; if (strstr(info->factory_name, "sink") != NULL) diff --git a/src/modules/module-client-device/protocol-native.c b/src/modules/module-client-device/protocol-native.c index b70f6a84c..950e7b015 100644 --- a/src/modules/module-client-device/protocol-native.c +++ b/src/modules/module-client-device/protocol-native.c @@ -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; } diff --git a/src/modules/module-client-node/protocol-native.c b/src/modules/module-client-node/protocol-native.c index 0f7b69090..87ff7104e 100644 --- a/src/modules/module-client-node/protocol-native.c +++ b/src/modules/module-client-node/protocol-native.c @@ -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; } diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 411bd5098..1baa8368d 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -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; } diff --git a/src/modules/module-protocol-pulse/extensions/ext-stream-restore.c b/src/modules/module-protocol-pulse/extensions/ext-stream-restore.c index 072a3e1cf..501015b44 100644 --- a/src/modules/module-protocol-pulse/extensions/ext-stream-restore.c +++ b/src/modules/module-protocol-pulse/extensions/ext-stream-restore.c @@ -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"; diff --git a/src/modules/module-protocol-simple.c b/src/modules/module-protocol-simple.c index 6361a1f2d..234c86b78 100644 --- a/src/modules/module-protocol-simple.c +++ b/src/modules/module-protocol-simple.c @@ -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; diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 35a6c7a3e..8e3490f90 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -159,7 +159,7 @@ static int update_properties(struct pw_impl_client *client, const struct spa_dic for (i = 0; i < dict->n_items; i++) { if (filter) { - if (strstr(dict->items[i].key, "pipewire.") == dict->items[i].key && + if (spa_strstartswith(dict->items[i].key, "pipewire.") && (old = pw_properties_get(client->properties, dict->items[i].key)) != NULL && (dict->items[i].value == NULL || !spa_streq(old, dict->items[i].value))) { pw_log_warn(NAME" %p: refuse property update '%s' from '%s' to '%s'",