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