treewide: replace strcmp() != 0 with !spa_streq

This change is only done in source files for now, header files will be done
separately.
This commit is contained in:
Peter Hutterer 2021-05-18 11:43:49 +10:00
parent 95a84e797a
commit 522f87d5ea
40 changed files with 83 additions and 79 deletions

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -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,

View file

@ -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 &&

View file

@ -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))

View file

@ -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));

View file

@ -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;
}

View file

@ -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));

View file

@ -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;
}

View file

@ -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) {

View file

@ -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);

View file

@ -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);

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
#include <spa/pod/builder.h>
@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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));

View file

@ -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;
}

View file

@ -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);

View file

@ -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, "")) {

View file

@ -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);

View file

@ -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 &&

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -61,6 +61,7 @@ ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
}
#endif
#include <spa/utils/string.h>
#include <spa/debug/types.h>
#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)

View file

@ -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);

View file

@ -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");

View file

@ -30,6 +30,7 @@
#include <spa/param/audio/format-utils.h>
#include <spa/node/utils.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/debug/types.h>
#include <spa/pod/filter.h>
@ -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 {

View file

@ -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,

View file

@ -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;
}

View file

@ -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) {

View file

@ -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) {