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

@ -32,6 +32,7 @@
#include <spa/node/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/buffer/alloc.h>
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
@ -1096,7 +1097,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;

View file

@ -32,6 +32,7 @@
#include <spa/utils/result.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/buffer/alloc.h>
#include <spa/node/io.h>
@ -1190,7 +1191,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;

View file

@ -32,6 +32,7 @@
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/node/keys.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
@ -1312,7 +1313,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;
@ -1336,7 +1337,7 @@ static uint32_t channel_from_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;
@ -1391,18 +1392,18 @@ impl_init(const struct spa_handle_factory *factory,
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
const char *s = info->items[i].value;
if (strcmp(k, "channelmix.normalize") == 0 &&
(strcmp(s, "true") == 0 || atoi(s) != 0))
if (spa_streq(k, "channelmix.normalize") &&
(spa_streq(s, "true") || atoi(s) != 0))
this->mix.options |= CHANNELMIX_OPTION_NORMALIZE;
if (strcmp(k, "channelmix.mix-lfe") == 0 &&
(strcmp(s, "true") == 0 || atoi(s) != 0))
if (spa_streq(k, "channelmix.mix-lfe") &&
(spa_streq(s, "true") || atoi(s) != 0))
this->mix.options |= CHANNELMIX_OPTION_MIX_LFE;
if (strcmp(k, "channelmix.upmix") == 0 &&
(strcmp(s, "true") == 0 || atoi(s) != 0))
if (spa_streq(k, "channelmix.upmix") &&
(spa_streq(s, "true") || atoi(s) != 0))
this->mix.options |= CHANNELMIX_OPTION_UPMIX;
if (strcmp(k, "channelmix.lfe-cutoff") == 0)
if (spa_streq(k, "channelmix.lfe-cutoff"))
this->mix.lfe_cutoff = atoi(s);
if (strcmp(k, SPA_KEY_AUDIO_POSITION) == 0)
if (spa_streq(k, SPA_KEY_AUDIO_POSITION))
this->props.n_channels = parse_position(this->props.channel_map, s, strlen(s));
}
this->props.channel.n_volumes = this->props.n_channels;

View file

@ -32,6 +32,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -952,7 +953,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;

View file

@ -33,6 +33,7 @@
#include <spa/utils/result.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -1336,7 +1337,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;
@ -1384,7 +1385,7 @@ impl_init(const struct spa_handle_factory *factory,
this->monitor_channel_volumes = false;
if (info) {
if ((str = spa_dict_lookup(info, "monitor.channel-volumes")) != NULL)
this->monitor_channel_volumes = strcmp(str, "true") == 0 || atoi(str) == 1;
this->monitor_channel_volumes = spa_streq(str, "true") || atoi(str) == 1;
}
this->node.iface = SPA_INTERFACE_INIT(

View file

@ -30,6 +30,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -947,7 +948,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;
@ -1006,11 +1007,11 @@ impl_init(const struct spa_handle_factory *factory,
if ((str = spa_dict_lookup(info, "resample.quality")) != NULL)
this->props.quality = atoi(str);
if ((str = spa_dict_lookup(info, "resample.peaks")) != NULL)
this->peaks = strcmp(str, "true") == 0 || atoi(str) == 1;
this->peaks = spa_streq(str, "true") || atoi(str) == 1;
if ((str = spa_dict_lookup(info, "factory.mode")) != NULL) {
if (strcmp(str, "split") == 0)
if (spa_streq(str, "split"))
this->mode = MODE_SPLIT;
else if (strcmp(str, "merge") == 0)
else if (spa_streq(str, "merge"))
this->mode = MODE_MERGE;
else
this->mode = MODE_CONVERT;

View file

@ -32,6 +32,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -1017,7 +1018,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;

View file

@ -30,6 +30,7 @@
#include <time.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/plugin.h>
#include <spa/param/param.h>
#include <spa/param/audio/format.h>
@ -56,7 +57,7 @@ static const struct spa_handle_factory *find_factory(const char *name)
const struct spa_handle_factory *factory;
while (spa_handle_factory_enum(&factory, &index) == 1) {
if (strcmp(factory->name, name) == 0)
if (spa_streq(factory->name, name))
return factory;
}
return NULL;

View file

@ -30,6 +30,7 @@
#include <time.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/plugin.h>
#include <spa/param/param.h>
#include <spa/param/audio/format.h>
@ -59,7 +60,7 @@ static const struct spa_handle_factory *find_factory(const char *name)
const struct spa_handle_factory *factory;
while (spa_handle_factory_enum(&factory, &index) == 1) {
if (strcmp(factory->name, name) == 0)
if (spa_streq(factory->name, name))
return factory;
}
return NULL;

View file

@ -31,6 +31,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -799,7 +800,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Node))
*interface = &this->node;
else
return -ENOENT;