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:36:13 +10:00
parent d8a9534a9a
commit 7697ed0757
130 changed files with 817 additions and 675 deletions

View file

@ -62,6 +62,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/debug/dict.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
@ -147,7 +148,7 @@ static struct sample *find_sample(struct impl *impl, uint32_t idx, const char *n
pw_array_for_each(item, &impl->samples.items) {
struct sample *s = item->data;
if (!pw_map_item_is_free(item) &&
strcmp(s->name, name) == 0)
spa_streq(s->name, name))
return s;
}
return NULL;
@ -726,11 +727,11 @@ static void send_default_change_subscribe_event(struct client *client, bool sink
static void handle_metadata(struct client *client, struct pw_manager_object *old,
struct pw_manager_object *new, const char *name)
{
if (strcmp(name, "default") == 0) {
if (spa_streq(name, "default")) {
if (client->metadata_default == old)
client->metadata_default = new;
}
else if (strcmp(name, "route-settings") == 0) {
else if (spa_streq(name, "route-settings")) {
if (client->metadata_routes == old)
client->metadata_routes = new;
}
@ -743,7 +744,7 @@ static void manager_added(void *data, struct pw_manager_object *o)
register_object_message_handlers(o);
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (spa_streq(o->type, PW_TYPE_INTERFACE_Metadata)) {
if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, NULL, o, str);
@ -774,7 +775,7 @@ static void manager_removed(void *data, struct pw_manager_object *o)
send_default_change_subscribe_event(client, pw_manager_object_is_sink(o), pw_manager_object_is_source_or_monitor(o));
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (spa_streq(o->type, PW_TYPE_INTERFACE_Metadata)) {
if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, o, NULL, str);
@ -792,7 +793,7 @@ static int json_object_find(const char *obj, const char *key, char *value, size_
return -EINVAL;
while (spa_json_get_string(&it[1], k, sizeof(k)-1) > 0) {
if (strcmp(k, key) == 0) {
if (spa_streq(k, key)) {
if (spa_json_get_string(&it[1], value, len) <= 0)
continue;
return 0;
@ -825,7 +826,7 @@ static void manager_metadata(void *data, struct pw_manager_object *o,
if (subject == PW_ID_CORE && o == client->metadata_default) {
char name[1024];
if (key == NULL || strcmp(key, "default.audio.sink") == 0) {
if (key == NULL || spa_streq(key, "default.audio.sink")) {
if (value != NULL) {
if (json_object_find(value,
"name", name, sizeof(name)) < 0)
@ -838,7 +839,7 @@ static void manager_metadata(void *data, struct pw_manager_object *o,
client->default_sink = value ? strdup(value) : NULL;
}
}
if (key == NULL || strcmp(key, "default.audio.source") == 0) {
if (key == NULL || spa_streq(key, "default.audio.source")) {
if (value != NULL) {
if (json_object_find(value,
"name", name, sizeof(name)) < 0)
@ -2597,7 +2598,7 @@ static struct pw_manager_object *find_device(struct client *client,
if (pw_endswith(name, ".monitor")) {
name = strndupa(name, strlen(name)-8);
monitor = true;
} else if (strcmp(name, DEFAULT_MONITOR) == 0) {
} else if (spa_streq(name, DEFAULT_MONITOR)) {
name = NULL;
monitor = true;
}
@ -2626,8 +2627,8 @@ static struct pw_manager_object *find_device(struct client *client,
def = DEFAULT_SOURCE;
}
if (id == SPA_ID_INVALID &&
(sel.value == NULL || strcmp(sel.value, def) == 0 ||
strcmp(sel.value, "0") == 0))
(sel.value == NULL || spa_streq(sel.value, def) ||
spa_streq(sel.value, "0")))
sel.value = get_default(client, sink);
return select_object(client->manager, &sel);
@ -4412,7 +4413,7 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
if (command == COMMAND_GET_SINK_INFO || command == COMMAND_GET_SOURCE_INFO) {
if ((sel.value == NULL && (sel.id == SPA_ID_INVALID || sel.id == 0)) ||
(sel.value != NULL && (strcmp(sel.value, def) == 0 || strcmp(sel.value, "0") == 0)))
(sel.value != NULL && (spa_streq(sel.value, def) || spa_streq(sel.value, "0"))))
sel.value = get_default(client, command == COMMAND_GET_SINK_INFO);
} else {
if (sel.value == NULL && sel.id == SPA_ID_INVALID)
@ -5144,7 +5145,7 @@ static int do_send_object_message(struct client *client, uint32_t command, uint3
res = -ENOENT;
spa_list_for_each(o, &manager->object_list, link) {
if (o->message_object_path && strcmp(o->message_object_path, path) == 0) {
if (o->message_object_path && spa_streq(o->message_object_path, path)) {
if (o->message_handler)
res = o->message_handler(manager, o, message, params, &response);
else