From 522f87d5eaed173237d6259339844e90d92ec8db Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 18 May 2021 11:43:49 +1000 Subject: [PATCH] treewide: replace strcmp() != 0 with !spa_streq This change is only done in source files for now, header files will be done separately. --- pipewire-alsa/alsa-plugins/ctl_pipewire.c | 6 +++--- pipewire-jack/src/pipewire-jack.c | 4 ++-- spa/plugins/alsa/acp/acp.c | 2 +- spa/plugins/bluez5/backend-hsphfpd.c | 14 +++++++------- spa/plugins/bluez5/backend-ofono.c | 4 ++-- spa/plugins/bluez5/bluez5-dbus.c | 10 +++++----- src/examples/bluez-session.c | 5 +++-- src/examples/media-session/access-flatpak.c | 2 +- src/examples/media-session/access-portal.c | 8 ++++---- src/examples/media-session/alsa-endpoint.c | 4 ++-- src/examples/media-session/alsa-monitor.c | 4 ++-- src/examples/media-session/bluez-endpoint.c | 4 ++-- src/examples/media-session/bluez-monitor.c | 4 ++-- src/examples/media-session/default-nodes.c | 4 ++-- src/examples/media-session/default-profile.c | 4 ++-- src/examples/media-session/default-routes.c | 6 +++--- src/examples/media-session/libcamera-monitor.c | 5 +++-- src/examples/media-session/media-session.c | 2 +- src/examples/media-session/policy-ep.c | 2 +- src/examples/media-session/policy-node.c | 4 ++-- src/examples/media-session/reserve.c | 8 ++++---- src/examples/media-session/restore-stream.c | 4 ++-- src/examples/media-session/stream-endpoint.c | 2 +- src/examples/media-session/v4l2-endpoint.c | 4 ++-- src/examples/media-session/v4l2-monitor.c | 4 ++-- src/modules/module-filter-chain.c | 2 +- src/modules/module-portal.c | 2 +- .../module-protocol-pulse/ext-stream-restore.c | 4 ++-- src/modules/module-protocol-pulse/manager.c | 2 +- src/modules/module-protocol-pulse/pulse-server.c | 2 +- src/pipewire/context.c | 2 +- src/pipewire/impl-client.c | 2 +- src/pipewire/impl-core.c | 5 +++-- src/pipewire/impl-device.c | 2 +- src/pipewire/impl-node.c | 4 ++-- src/pipewire/impl-port.c | 3 ++- src/tests/test-endpoint.c | 2 +- src/tools/pw-cli.c | 4 ++-- src/tools/pw-metadata.c | 4 ++-- src/tools/pw-profiler.c | 2 +- 40 files changed, 83 insertions(+), 79 deletions(-) diff --git a/pipewire-alsa/alsa-plugins/ctl_pipewire.c b/pipewire-alsa/alsa-plugins/ctl_pipewire.c index 4972bd309..4ffe8fd75 100644 --- a/pipewire-alsa/alsa-plugins/ctl_pipewire.c +++ b/pipewire-alsa/alsa-plugins/ctl_pipewire.c @@ -1085,7 +1085,7 @@ static void registry_event_global(void *data, uint32_t id, if (spa_streq(type, PW_TYPE_INTERFACE_Device)) { if (props == NULL || ((str = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS)) == NULL) || - (strcmp(str, "Audio/Device") != 0)) + (!spa_streq(str, "Audio/Device"))) return; pw_log_debug("found device %d", id); @@ -1093,8 +1093,8 @@ static void registry_event_global(void *data, uint32_t id, } else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { if (props == NULL || ((str = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS)) == NULL) || - ((strcmp(str, "Audio/Sink") != 0) && - (strcmp(str, "Audio/Source") != 0))) + ((!spa_streq(str, "Audio/Sink")) && + (!spa_streq(str, "Audio/Source")))) return; pw_log_debug("found node %d type:%s", id, str); diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index cc978045e..0a621dde6 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -2213,7 +2213,7 @@ static void registry_event_global(void *data, uint32_t id, if (str == NULL) str = "node"; - if (app && strcmp(app, str) != 0) + if (app && !spa_streq(app, str)) snprintf(tmp, sizeof(tmp), "%s/%s", app, str); else snprintf(tmp, sizeof(tmp), "%s", str); @@ -2702,7 +2702,7 @@ jack_client_t * jack_client_open (const char *client_name, break; } - if (strcmp(client->name, client_name) != 0) { + if (!spa_streq(client->name, client_name)) { if (status) *status |= JackNameNotUnique; if (options & JackUseExactName) diff --git a/spa/plugins/alsa/acp/acp.c b/spa/plugins/alsa/acp/acp.c index e481cd19a..21cb9b4e8 100644 --- a/spa/plugins/alsa/acp/acp.c +++ b/spa/plugins/alsa/acp/acp.c @@ -869,7 +869,7 @@ static int hdmi_eld_changed(snd_mixer_elem_t *melem, unsigned int mask) changed |= old_monitor_name != NULL; pa_proplist_unset(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME); } else { - changed |= (old_monitor_name == NULL) || (strcmp(old_monitor_name, eld.monitor_name) != 0); + changed |= (old_monitor_name == NULL) || (!spa_streq(old_monitor_name, eld.monitor_name)); pa_proplist_sets(p->proplist, PA_PROP_DEVICE_PRODUCT_NAME, eld.monitor_name); } pa_proplist_as_dict(p->proplist, &p->port.props); diff --git a/spa/plugins/bluez5/backend-hsphfpd.c b/spa/plugins/bluez5/backend-hsphfpd.c index 17b701bb9..6fe4616bc 100644 --- a/spa/plugins/bluez5/backend-hsphfpd.c +++ b/spa/plugins/bluez5/backend-hsphfpd.c @@ -477,10 +477,10 @@ static DBusHandlerResult audio_agent_get_property(DBusConnection *conn, DBusMess goto fail; } - if (strcmp(interface, HSPHFPD_AUDIO_AGENT_INTERFACE) != 0) + if (!spa_streq(interface, HSPHFPD_AUDIO_AGENT_INTERFACE)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - if (strcmp(property, "AgentCodec") != 0) { + if (!spa_streq(property, "AgentCodec")) { r = dbus_message_new_error(m, DBUS_ERROR_INVALID_ARGS, "Invalid property in method call"); goto fail; } @@ -536,7 +536,7 @@ static DBusHandlerResult audio_agent_getall_properties(DBusConnection *conn, DBu goto fail; } - if (strcmp(interface, HSPHFPD_AUDIO_AGENT_INTERFACE) != 0) + if (!spa_streq(interface, HSPHFPD_AUDIO_AGENT_INTERFACE)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if ((r = dbus_message_new_method_return(m)) == NULL) @@ -593,7 +593,7 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus spa_log_debug(backend->log, NAME": NewConnection %s, fd %d", transport_path, fd); sender = dbus_message_get_sender(m); - if (strcmp(sender, backend->hsphfpd_service_id) != 0) { + if (!spa_streq(sender, backend->hsphfpd_service_id)) { close(fd); spa_log_error(backend->log, NAME": Sender '%s' is not authorized", sender); r = dbus_message_new_error_printf(m, HSPHFPD_ERROR_REJECTED, "Sender '%s' is not authorized", sender); @@ -872,7 +872,7 @@ static void hsphfpd_audio_acquire_reply(DBusPendingCall *pending, void *user_dat goto finish; } - if (strcmp(dbus_message_get_sender(r), backend->hsphfpd_service_id) != 0) { + if (!spa_streq(dbus_message_get_sender(r), backend->hsphfpd_service_id)) { spa_log_error(backend->log, NAME": Reply for " HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio() from invalid sender"); goto finish; } @@ -891,7 +891,7 @@ static void hsphfpd_audio_acquire_reply(DBusPendingCall *pending, void *user_dat goto finish; } - if (strcmp(service_id, dbus_bus_get_unique_name(backend->conn)) != 0) { + if (!spa_streq(service_id, dbus_bus_get_unique_name(backend->conn))) { spa_log_warn(backend->log, HSPHFPD_ENDPOINT_INTERFACE ".ConnectAudio() failed: Other audio application took audio socket"); goto finish; } @@ -1200,7 +1200,7 @@ static void hsphfpd_get_endpoints_reply(DBusPendingCall *pending, void *user_dat goto finish; } - if (strcmp(dbus_message_get_sender(r), backend->hsphfpd_service_id) != 0) { + if (!spa_streq(dbus_message_get_sender(r), backend->hsphfpd_service_id)) { spa_log_error(backend->log, NAME": Reply for GetManagedObjects() from invalid sender"); goto finish; } diff --git a/spa/plugins/bluez5/backend-ofono.c b/spa/plugins/bluez5/backend-ofono.c index 2d2bce1a3..82f456876 100644 --- a/spa/plugins/bluez5/backend-ofono.c +++ b/spa/plugins/bluez5/backend-ofono.c @@ -559,7 +559,7 @@ static void ofono_getcards_reply(DBusPendingCall *pending, void *user_data) goto finish; } - if (!dbus_message_iter_init(r, &i) || strcmp(dbus_message_get_signature(r), "a(oa{sv})") != 0) { + if (!dbus_message_iter_init(r, &i) || !spa_streq(dbus_message_get_signature(r), "a(oa{sv})")) { spa_log_error(backend->log, NAME": Invalid arguments in GetCards() reply"); goto finish; } @@ -682,7 +682,7 @@ static DBusHandlerResult ofono_filter_cb(DBusConnection *bus, DBusMessage *m, vo char *p; DBusMessageIter arg_i, props_i; - if (!dbus_message_iter_init(m, &arg_i) || strcmp(dbus_message_get_signature(m), "oa{sv}") != 0) { + if (!dbus_message_iter_init(m, &arg_i) || !spa_streq(dbus_message_get_signature(m), "oa{sv}")) { spa_log_error(backend->log, NAME": Failed to parse org.ofono.HandsfreeAudioManager.CardAdded"); goto fail; } diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 9d654c272..0c6cc2de3 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -3281,7 +3281,7 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *user_data) } if (!dbus_message_iter_init(r, &it[0]) || - strcmp(dbus_message_get_signature(r), "a{oa{sa{sv}}}") != 0) { + !spa_streq(dbus_message_get_signature(r), "a{oa{sa{sv}}}")) { spa_log_error(monitor->log, "Invalid reply signature for GetManagedObjects()"); goto finish; } @@ -3427,7 +3427,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us if (!monitor->objects_listed) goto finish; - if (!dbus_message_iter_init(m, &it) || strcmp(dbus_message_get_signature(m), "oa{sa{sv}}") != 0) { + if (!dbus_message_iter_init(m, &it) || !spa_streq(dbus_message_get_signature(m), "oa{sa{sv}}")) { spa_log_error(monitor->log, NAME": Invalid signature found in InterfacesAdded"); goto finish; } @@ -3441,7 +3441,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us if (!monitor->objects_listed) goto finish; - if (!dbus_message_iter_init(m, &it) || strcmp(dbus_message_get_signature(m), "oas") != 0) { + if (!dbus_message_iter_init(m, &it) || !spa_streq(dbus_message_get_signature(m), "oas")) { spa_log_error(monitor->log, NAME": Invalid signature found in InterfacesRemoved"); goto finish; } @@ -3455,7 +3455,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us goto finish; if (!dbus_message_iter_init(m, &it[0]) || - strcmp(dbus_message_get_signature(m), "sa{sv}as") != 0) { + !spa_streq(dbus_message_get_signature(m), "sa{sv}as")) { spa_log_error(monitor->log, "Invalid signature found in PropertiesChanged"); goto finish; } @@ -3779,7 +3779,7 @@ static int parse_codec_array(struct spa_bt_monitor *this, const struct spa_dict for (i = 0; a2dp_codecs[i]; ++i) { const struct a2dp_codec *codec = a2dp_codecs[i]; - if (strcmp(codec->name, codec_name) != 0) + if (!spa_streq(codec->name, codec_name)) continue; if (spa_dict_lookup_item(&this->enabled_codecs, codec->name) != NULL) diff --git a/src/examples/bluez-session.c b/src/examples/bluez-session.c index 6133ec717..08d2b9e1d 100644 --- a/src/examples/bluez-session.c +++ b/src/examples/bluez-session.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -116,7 +117,7 @@ static struct node *create_node(struct object *obj, uint32_t id, pw_log_debug("new node %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) return NULL; handle = pw_context_load_spa_handle(context, @@ -225,7 +226,7 @@ static struct object *create_object(struct impl *impl, uint32_t id, pw_log_debug("new object %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) return NULL; handle = pw_context_load_spa_handle(context, diff --git a/src/examples/media-session/access-flatpak.c b/src/examples/media-session/access-flatpak.c index 95984a540..c93b42eb2 100644 --- a/src/examples/media-session/access-flatpak.c +++ b/src/examples/media-session/access-flatpak.c @@ -73,7 +73,7 @@ static void object_update(void *data) if (client->obj->info == NULL || client->obj->info->props == NULL || (str = spa_dict_lookup(client->obj->info->props, PW_KEY_ACCESS)) == NULL || - strcmp(str, "flatpak") != 0) + !spa_streq(str, "flatpak")) return; if ((str = spa_dict_lookup(client->obj->info->props, PW_KEY_MEDIA_CATEGORY)) != NULL && diff --git a/src/examples/media-session/access-portal.c b/src/examples/media-session/access-portal.c index a816fa89a..39eeb314d 100644 --- a/src/examples/media-session/access-portal.c +++ b/src/examples/media-session/access-portal.c @@ -131,7 +131,7 @@ static enum media_role media_role_from_properties(const struct pw_properties *pr if (media_role_str == NULL) return MEDIA_ROLE_INVALID; - if (strcmp(media_class_str, "Video/Source") != 0) + if (!spa_streq(media_class_str, "Video/Source")) return MEDIA_ROLE_INVALID; return media_role_from_string(media_role_str); @@ -405,7 +405,7 @@ static void do_permission_store_check(struct client *client) dbus_message_iter_get_basic(&permissions_entry_iter, &app_id); pw_log_info("permissions %s", app_id); - if (strcmp(app_id, client->app_id) != 0) { + if (!spa_streq(app_id, client->app_id)) { dbus_message_iter_next(&permissions_iter); continue; } @@ -514,7 +514,7 @@ static DBusHandlerResult permission_store_changed_handler(DBusConnection *connec dbus_message_iter_next(&iter); dbus_message_iter_get_basic(&iter, &id); - if (strcmp(table, "devices") != 0 || strcmp(id, "camera") != 0) + if (!spa_streq(table, "devices") || !spa_streq(id, "camera")) return DBUS_HANDLER_RESULT_HANDLED; dbus_message_iter_next(&iter); @@ -550,7 +550,7 @@ static DBusHandlerResult permission_store_changed_handler(DBusConnection *connec continue; if (client->app_id == NULL || - strcmp(client->app_id, app_id) != 0) + !spa_streq(client->app_id, app_id)) continue; if (!(client->media_roles & MEDIA_ROLE_CAMERA)) diff --git a/src/examples/media-session/alsa-endpoint.c b/src/examples/media-session/alsa-endpoint.c index 5fc7c42ff..d3ccd7d9e 100644 --- a/src/examples/media-session/alsa-endpoint.c +++ b/src/examples/media-session/alsa-endpoint.c @@ -196,7 +196,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop goto exit; } obj = sm_media_session_find_object(impl->session, atoi(str)); - if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) !=0) { + if (obj == NULL || !spa_streq(obj->type, PW_TYPE_INTERFACE_Endpoint)) { pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj); res = -EINVAL; goto exit; @@ -681,7 +681,7 @@ handle_device(struct impl *impl, struct sm_object *obj) if (strstr(media_class, "Audio/") != media_class) return 0; - if (strcmp(str, "alsa") != 0) + if (!spa_streq(str, "alsa")) return 0; device = sm_object_add_data(obj, SESSION_KEY, sizeof(struct device)); diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index 2c0f07455..7a8cc256b 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -273,7 +273,7 @@ static struct node *alsa_create_node(struct device *device, uint32_t id, if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) spa_debug_dict(0, info->props); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) { errno = EINVAL; return NULL; } @@ -959,7 +959,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id, if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) spa_debug_dict(0, info->props); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) { errno = EINVAL; return NULL; } diff --git a/src/examples/media-session/bluez-endpoint.c b/src/examples/media-session/bluez-endpoint.c index b6b9a99cb..9d2158e5c 100644 --- a/src/examples/media-session/bluez-endpoint.c +++ b/src/examples/media-session/bluez-endpoint.c @@ -191,7 +191,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop goto exit; } obj = sm_media_session_find_object(impl->session, atoi(str)); - if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) !=0) { + if (obj == NULL || !spa_streq(obj->type, PW_TYPE_INTERFACE_Endpoint)) { pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj); res = -EINVAL; goto exit; @@ -618,7 +618,7 @@ handle_device(struct impl *impl, struct sm_object *obj) if (strstr(media_class, "Audio/") != media_class) return 0; - if (strcmp(str, "bluez5") != 0) + if (!spa_streq(str, "bluez5")) return 0; device = sm_object_add_data(obj, SESSION_KEY, sizeof(struct device)); diff --git a/src/examples/media-session/bluez-monitor.c b/src/examples/media-session/bluez-monitor.c index f6a6b23eb..49301d7b0 100644 --- a/src/examples/media-session/bluez-monitor.c +++ b/src/examples/media-session/bluez-monitor.c @@ -196,7 +196,7 @@ static struct node *bluez5_create_node(struct device *device, uint32_t id, pw_log_debug("new node %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) { errno = EINVAL; return NULL; } @@ -472,7 +472,7 @@ static struct device *bluez5_create_device(struct impl *impl, uint32_t id, pw_log_debug("new device %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) { errno = EINVAL; return NULL; } diff --git a/src/examples/media-session/default-nodes.c b/src/examples/media-session/default-nodes.c index 0720f25c0..4a9d7e7dd 100644 --- a/src/examples/media-session/default-nodes.c +++ b/src/examples/media-session/default-nodes.c @@ -223,7 +223,7 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; const struct spa_dict_item *item; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) != 0) + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Node)) return; spa_dict_for_each(item, &impl->properties->dict) { @@ -253,7 +253,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; struct default_node *def; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) != 0) + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Node)) return; for (def = impl->defaults; def->key != NULL; ++def) { diff --git a/src/examples/media-session/default-profile.c b/src/examples/media-session/default-profile.c index 877ad0222..81c2500b9 100644 --- a/src/examples/media-session/default-profile.c +++ b/src/examples/media-session/default-profile.c @@ -387,7 +387,7 @@ static void session_create(void *data, struct sm_object *object) struct device *dev; const char *name; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) != 0 || + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Device) || object->props == NULL || (name = pw_properties_get(object->props, PW_KEY_DEVICE_NAME)) == NULL) return; @@ -421,7 +421,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; struct device *dev; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) != 0) + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Device)) return; pw_log_debug(NAME " %p: remove device '%d'", impl, object->id); diff --git a/src/examples/media-session/default-routes.c b/src/examples/media-session/default-routes.c index 453381f53..552e3e8c6 100644 --- a/src/examples/media-session/default-routes.c +++ b/src/examples/media-session/default-routes.c @@ -592,7 +592,7 @@ static int find_route(struct device *dev, uint32_t device_id, const char *name, if (p->id != SPA_PARAM_EnumRoute || parse_enum_route(p, device_id, r) < 0) continue; - if (strcmp(r->name, name) != 0) + if (!spa_streq(r->name, name)) continue; return 0; } @@ -821,7 +821,7 @@ static void session_create(void *data, struct sm_object *object) struct device *dev; const char *name; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) != 0 || + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Device) || object->props == NULL || (name = pw_properties_get(object->props, PW_KEY_DEVICE_NAME)) == NULL) return; @@ -854,7 +854,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; struct device *dev; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) != 0) + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Device)) return; pw_log_debug(NAME " %p: remove device '%d'", impl, object->id); diff --git a/src/examples/media-session/libcamera-monitor.c b/src/examples/media-session/libcamera-monitor.c index 14b9edde7..a10af2ec4 100644 --- a/src/examples/media-session/libcamera-monitor.c +++ b/src/examples/media-session/libcamera-monitor.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -122,7 +123,7 @@ static struct node *libcamera_create_node(struct device *dev, uint32_t id, pw_log_debug("new node %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) { errno = EINVAL; return NULL; } @@ -353,7 +354,7 @@ static struct device *libcamera_create_device(struct impl *impl, uint32_t id, pw_log_debug("new device %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) { errno = EINVAL; return NULL; } diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 84eefbc41..31e6a1345 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -242,7 +242,7 @@ static void *find_object(struct impl *impl, uint32_t id, const char *type) struct sm_object *obj; if ((obj = pw_map_lookup(&impl->globals, id)) == NULL) return NULL; - if (type != NULL && strcmp(obj->type, type) != 0) + if (type != NULL && !spa_streq(obj->type, type)) return NULL; return obj; } diff --git a/src/examples/media-session/policy-ep.c b/src/examples/media-session/policy-ep.c index c5d1bbb4b..22c344e65 100644 --- a/src/examples/media-session/policy-ep.c +++ b/src/examples/media-session/policy-ep.c @@ -278,7 +278,7 @@ static int find_endpoint(void *data, struct endpoint *endpoint) pw_log_debug(".. same direction"); return 0; } - if (strcmp(endpoint->media, find->ep->media) != 0) { + if (!spa_streq(endpoint->media, find->ep->media)) { pw_log_debug(".. incompatible media %s <-> %s", endpoint->media, find->ep->media); return 0; } diff --git a/src/examples/media-session/policy-node.c b/src/examples/media-session/policy-node.c index 8d435eb41..9f86dd0b0 100644 --- a/src/examples/media-session/policy-node.c +++ b/src/examples/media-session/policy-node.c @@ -197,7 +197,7 @@ static int configure_node(struct node *node, struct spa_audio_info *info, bool f if (node->configured && !force) return 0; - if (strcmp(node->media, "Audio") != 0) + if (!spa_streq(node->media, "Audio")) return 0; format = node->format; @@ -550,7 +550,7 @@ static int find_node(void *data, struct node *node) return 0; } - if (node->media && strcmp(node->media, find->media) != 0) { + if (node->media && !spa_streq(node->media, find->media)) { pw_log_debug(".. incompatible media %s <-> %s", node->media, find->media); return 0; } diff --git a/src/examples/media-session/reserve.c b/src/examples/media-session/reserve.c index 072ead2fa..cb41d8c82 100644 --- a/src/examples/media-session/reserve.c +++ b/src/examples/media-session/reserve.c @@ -257,7 +257,7 @@ static DBusHandlerResult filter_handler(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INVALID)) goto invalid; - if (strcmp(name, d->service_name) != 0) + if (!spa_streq(name, d->service_name)) goto invalid; pw_log_debug(NAME" %p: acquired %s, %s", d, name, d->service_name); @@ -271,7 +271,7 @@ static DBusHandlerResult filter_handler(DBusConnection *c, DBusMessage *m, void d))) goto invalid; - if (strcmp(name, d->service_name) != 0) + if (!spa_streq(name, d->service_name)) goto invalid; d->registered = true; @@ -285,7 +285,7 @@ static DBusHandlerResult filter_handler(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INVALID)) goto invalid; - if (strcmp(name, d->service_name) != 0) + if (!spa_streq(name, d->service_name)) goto invalid; pw_log_debug(NAME" %p: lost %s", d, name); @@ -307,7 +307,7 @@ static DBusHandlerResult filter_handler(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INVALID)) goto invalid; - if (strcmp(name, d->service_name) != 0 || d->owning) + if (!spa_streq(name, d->service_name) || d->owning) goto invalid; pw_log_debug(NAME" %p: changed %s: %s -> %s", d, name, old, new); diff --git a/src/examples/media-session/restore-stream.c b/src/examples/media-session/restore-stream.c index 7a4022b88..897214e9d 100644 --- a/src/examples/media-session/restore-stream.c +++ b/src/examples/media-session/restore-stream.c @@ -466,7 +466,7 @@ static void session_create(void *data, struct sm_object *object) struct stream *str; const char *media_class, *routes; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) != 0 || + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Node) || object->props == NULL || (media_class = pw_properties_get(object->props, PW_KEY_MEDIA_CLASS)) == NULL) return; @@ -506,7 +506,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; struct stream *str; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) != 0) + if (!spa_streq(object->type, PW_TYPE_INTERFACE_Node)) return; pw_log_debug(NAME " %p: remove node '%d'", impl, object->id); diff --git a/src/examples/media-session/stream-endpoint.c b/src/examples/media-session/stream-endpoint.c index 8d44b03fd..239062774 100644 --- a/src/examples/media-session/stream-endpoint.c +++ b/src/examples/media-session/stream-endpoint.c @@ -209,7 +209,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop goto exit; } obj = sm_media_session_find_object(impl->session, atoi(str)); - if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) { + if (obj == NULL || !spa_streq(obj->type, PW_TYPE_INTERFACE_Endpoint)) { pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj); res = -EINVAL; goto exit; diff --git a/src/examples/media-session/v4l2-endpoint.c b/src/examples/media-session/v4l2-endpoint.c index be469ff38..35f1bc302 100644 --- a/src/examples/media-session/v4l2-endpoint.c +++ b/src/examples/media-session/v4l2-endpoint.c @@ -162,7 +162,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop goto exit; } obj = sm_media_session_find_object(impl->session, atoi(str)); - if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) { + if (obj == NULL || !spa_streq(obj->type, PW_TYPE_INTERFACE_Endpoint)) { pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj); res = -EINVAL; goto exit; @@ -565,7 +565,7 @@ handle_device(struct impl *impl, struct sm_object *obj) if (strstr(media_class, "Video/") != media_class) return 0; - if (strcmp(str, "v4l2") != 0) + if (!spa_streq(str, "v4l2")) return 0; device = sm_object_add_data(obj, SESSION_KEY, sizeof(struct device)); diff --git a/src/examples/media-session/v4l2-monitor.c b/src/examples/media-session/v4l2-monitor.c index 3dfa9f4d8..6de9b6142 100644 --- a/src/examples/media-session/v4l2-monitor.c +++ b/src/examples/media-session/v4l2-monitor.c @@ -133,7 +133,7 @@ static struct node *v4l2_create_node(struct device *dev, uint32_t id, pw_log_debug("new node %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) { errno = EINVAL; return NULL; } @@ -417,7 +417,7 @@ static struct device *v4l2_create_device(struct impl *impl, uint32_t id, pw_log_debug("new device %u", id); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) { + if (!spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) { errno = EINVAL; return NULL; } diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index 10a6db508..4639ed5d3 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -1075,7 +1075,7 @@ static int load_node(struct graph *graph, struct spa_json *json) if (spa_streq(type, "builtin")) { snprintf(plugin, sizeof(plugin), "%s", "builtin"); - } else if (strcmp(type, "ladspa") != 0) + } else if (!spa_streq(type, "ladspa")) return -ENOTSUP; pw_log_info("loading %s %s", plugin, label); diff --git a/src/modules/module-portal.c b/src/modules/module-portal.c index c6e632114..e7f648a84 100644 --- a/src/modules/module-portal.c +++ b/src/modules/module-portal.c @@ -213,7 +213,7 @@ static DBusHandlerResult name_owner_changed_handler(DBusConnection *connection, return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } - if (strcmp(name, "org.freedesktop.portal.Desktop") != 0) + if (!spa_streq(name, "org.freedesktop.portal.Desktop")) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (spa_streq(new_owner, "")) { diff --git a/src/modules/module-protocol-pulse/ext-stream-restore.c b/src/modules/module-protocol-pulse/ext-stream-restore.c index fd5b2cdbc..e8c3c2070 100644 --- a/src/modules/module-protocol-pulse/ext-stream-restore.c +++ b/src/modules/module-protocol-pulse/ext-stream-restore.c @@ -242,8 +242,8 @@ static int do_extension_stream_restore_write(struct client *client, uint32_t com fprintf(f, " ]"); } if (device_name != NULL && device_name[0] && - (client->default_source == NULL || strcmp(device_name, client->default_source) != 0) && - (client->default_sink == NULL || strcmp(device_name, client->default_sink) != 0)) + (client->default_source == NULL || !spa_streq(device_name, client->default_source)) && + (client->default_sink == NULL || !spa_streq(device_name, client->default_sink))) fprintf(f, ", \"target-node\": \"%s\"", device_name); fprintf(f, " }"); fclose(f); diff --git a/src/modules/module-protocol-pulse/manager.c b/src/modules/module-protocol-pulse/manager.c index da567f0e5..bc4ad3899 100644 --- a/src/modules/module-protocol-pulse/manager.c +++ b/src/modules/module-protocol-pulse/manager.c @@ -350,7 +350,7 @@ static struct object *find_device(struct manager *m, uint32_t card_id, uint32_t struct pw_node_info *info; const char *str; - if (strcmp(o->this.type, PW_TYPE_INTERFACE_Node) != 0) + if (!spa_streq(o->this.type, PW_TYPE_INTERFACE_Node)) continue; if ((info = o->this.info) != NULL && diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 92f93118e..4cfc30ee4 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -3355,7 +3355,7 @@ static int do_set_port_latency_offset(struct client *client, uint32_t command, u struct port_info *pi = &port_info[i]; size_t j; - if (strcmp(pi->name, port_name) != 0) + if (!spa_streq(pi->name, port_name)) continue; res = 0; diff --git a/src/pipewire/context.c b/src/pipewire/context.c index 4619bb437..9c8b8ec8a 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -946,7 +946,7 @@ static int collect_nodes(struct pw_context *context, struct pw_impl_node *driver spa_list_for_each(t, &context->node_list, link) { if (t->exported || t == n || !t->active || t->visited) continue; - if (strcmp(t->group, n->group) != 0) + if (!spa_streq(t->group, n->group)) continue; pw_log_debug("%p join group %s: '%s'", t, t->group, n->group); t->visited = true; diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 33a51bd22..1af9d8518 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 if (filter) { if (strstr(dict->items[i].key, "pipewire.") == dict->items[i].key && (old = pw_properties_get(client->properties, dict->items[i].key)) != NULL && - (dict->items[i].value == NULL || strcmp(old, dict->items[i].value) != 0)) { + (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'", client, dict->items[i].key, old, dict->items[i].value); diff --git a/src/pipewire/impl-core.c b/src/pipewire/impl-core.c index 91f25267d..fa6cf18fd 100644 --- a/src/pipewire/impl-core.c +++ b/src/pipewire/impl-core.c @@ -61,6 +61,7 @@ ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) { } #endif +#include #include #include "pipewire/impl.h" @@ -93,7 +94,7 @@ static void * registry_bind(void *object, uint32_t id, if (!PW_PERM_IS_R(permissions)) goto error_no_id; - if (strcmp(global->type, type) != 0) + if (!spa_streq(global->type, type)) goto error_wrong_interface; pw_log_debug("global %p: bind global id %d, iface %s/%d to %d", global, id, @@ -339,7 +340,7 @@ core_create_object(void *object, if (!PW_PERM_IS_R(pw_global_get_permissions(factory->global, client))) goto error_no_factory; - if (strcmp(factory->info.type, type) != 0) + if (!spa_streq(factory->info.type, type)) goto error_type; if (factory->info.version < version) diff --git a/src/pipewire/impl-device.c b/src/pipewire/impl-device.c index 2d7d13e19..3aec93255 100644 --- a/src/pipewire/impl-device.c +++ b/src/pipewire/impl-device.c @@ -130,7 +130,7 @@ static void check_properties(struct pw_impl_device *device) const char *str; if ((str = pw_properties_get(device->properties, PW_KEY_DEVICE_NAME)) && - (device->name == NULL || strcmp(str, device->name) != 0)) { + (device->name == NULL || !spa_streq(str, device->name))) { free(device->name); device->name = strdup(str); pw_log_debug(NAME" %p: name '%s'", device, device->name); diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 57db6f3b2..6556a1439 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -825,7 +825,7 @@ static void check_properties(struct pw_impl_node *node) } if ((str = pw_properties_get(node->properties, PW_KEY_NODE_NAME)) && - (node->name == NULL || strcmp(node->name, str) != 0)) { + (node->name == NULL || !spa_streq(node->name, str))) { free(node->name); node->name = strdup(str); pw_log_debug(NAME" %p: name '%s'", node, node->name); @@ -862,7 +862,7 @@ static void check_properties(struct pw_impl_node *node) if ((str = pw_properties_get(node->properties, PW_KEY_NODE_GROUP)) == NULL) str = ""; - if (strcmp(str, node->group) != 0) { + if (!spa_streq(str, node->group)) { pw_log_info(NAME" %p: group '%s'->'%s'", node, node->group, str); snprintf(node->group, sizeof(node->group), "%s", str); node->freewheel = spa_streq(node->group, "pipewire.freewheel"); diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index 538f0b53a..7b91da4bc 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -923,7 +924,7 @@ int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node) if ((str = pw_properties_get(port->properties, PW_KEY_PORT_NAME)) == NULL) { if ((str = pw_properties_get(port->properties, PW_KEY_AUDIO_CHANNEL)) != NULL && - strcmp(str, "UNK") != 0) { + !spa_streq(str, "UNK")) { pw_properties_setf(port->properties, PW_KEY_PORT_NAME, "%s_%s", dir, str); } else { diff --git a/src/tests/test-endpoint.c b/src/tests/test-endpoint.c index 896a98bb6..31c4e44aa 100644 --- a/src/tests/test-endpoint.c +++ b/src/tests/test-endpoint.c @@ -344,7 +344,7 @@ test_endpoint_global(void *object, uint32_t id, struct test_endpoint_data *d = object; const char *val; - if (strcmp(type, PW_TYPE_INTERFACE_Endpoint) != 0) + if (!spa_streq(type, PW_TYPE_INTERFACE_Endpoint)) return; d->bound_proxy = pw_registry_bind(d->registry, id, type, diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index 10e53750b..cee33900c 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -1735,7 +1735,7 @@ static bool do_permissions(struct data *data, const char *cmd, char *args, char *error = spa_aprintf("%s: unknown global %d", cmd, id); return false; } - if (strcmp(global->type, PW_TYPE_INTERFACE_Client) != 0) { + if (!spa_streq(global->type, PW_TYPE_INTERFACE_Client)) { *error = spa_aprintf("object %d is not a client", atoi(a[0])); return false; } @@ -1775,7 +1775,7 @@ static bool do_get_permissions(struct data *data, const char *cmd, char *args, c *error = spa_aprintf("%s: unknown global %d", cmd, id); return false; } - if (strcmp(global->type, PW_TYPE_INTERFACE_Client) != 0) { + if (!spa_streq(global->type, PW_TYPE_INTERFACE_Client)) { *error = spa_aprintf("object %d is not a client", atoi(a[0])); return false; } diff --git a/src/tools/pw-metadata.c b/src/tools/pw-metadata.c index 89f42d414..faa83efdc 100644 --- a/src/tools/pw-metadata.c +++ b/src/tools/pw-metadata.c @@ -93,11 +93,11 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, struct data *d = data; const char *str; - if (strcmp(type, PW_TYPE_INTERFACE_Metadata) != 0) + if (!spa_streq(type, PW_TYPE_INTERFACE_Metadata)) return; if ((str = spa_dict_lookup(props, PW_KEY_METADATA_NAME)) != NULL && - strcmp(str, d->opt_name) != 0) + !spa_streq(str, d->opt_name)) return; if (d->metadata != NULL) { diff --git a/src/tools/pw-profiler.c b/src/tools/pw-profiler.c index 338741edf..9f1e8f476 100644 --- a/src/tools/pw-profiler.c +++ b/src/tools/pw-profiler.c @@ -475,7 +475,7 @@ static void registry_event_global(void *data, uint32_t id, struct data *d = data; struct pw_proxy *proxy; - if (strcmp(type, PW_TYPE_INTERFACE_Profiler) != 0) + if (!spa_streq(type, PW_TYPE_INTERFACE_Profiler)) return; if (d->profiler != NULL) {