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

@ -28,6 +28,7 @@
#include <arpa/inet.h>
#include <spa/param/audio/format.h>
#include <spa/utils/string.h>
#include <sbc/sbc.h>
@ -164,7 +165,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
if (caps_size < sizeof(conf))
return -EINVAL;
xq = (strcmp(codec->name, "sbc_xq") == 0);
xq = (spa_streq(codec->name, "sbc_xq"));
memcpy(&conf, caps, sizeof(conf));
@ -235,7 +236,7 @@ static int codec_caps_preference_cmp(const struct a2dp_codec *codec, const void
a2dp_sbc_t *conf;
int res1, res2;
int a, b;
bool xq = (strcmp(codec->name, "sbc_xq") == 0);
bool xq = (spa_streq(codec->name, "sbc_xq"));
/* Order selected configurations by preference */
res1 = codec->select_config(codec, 0, caps1, caps1_size, info, NULL, (uint8_t *)&conf1);

View file

@ -36,6 +36,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -1324,7 +1325,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

@ -39,6 +39,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -1236,7 +1237,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;
@ -1341,7 +1342,7 @@ impl_init(const struct spa_handle_factory *factory,
if ((str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT)) != NULL)
sscanf(str, "pointer:%p", &this->transport);
if ((str = spa_dict_lookup(info, "bluez5.a2dp-source-role")) != NULL)
this->is_input = strcmp(str, "input") == 0;
this->is_input = spa_streq(str, "input");
}
if (this->transport == NULL) {

View file

@ -33,6 +33,7 @@
#include <spa/support/loop.h>
#include <spa/support/dbus.h>
#include <spa/support/plugin.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/param/audio/raw.h>
@ -175,7 +176,7 @@ static struct hsphfpd_endpoint *endpoint_find(struct impl *backend, const char *
{
struct hsphfpd_endpoint *d;
spa_list_for_each(d, &backend->endpoint_list, link)
if (strcmp(d->path, path) == 0)
if (spa_streq(d->path, path))
return d;
return NULL;
}
@ -193,7 +194,7 @@ static void endpoint_free(struct hsphfpd_endpoint *endpoint)
static bool hsphfpd_cmp_transport_path(struct spa_bt_transport *t, const void *data)
{
struct hsphfpd_transport_data *td = t->user_data;
if (strcmp(td->transport_path, data) == 0)
if (spa_streq(td->transport_path, data))
return true;
return false;
@ -201,7 +202,7 @@ static bool hsphfpd_cmp_transport_path(struct spa_bt_transport *t, const void *d
static inline bool check_signature(DBusMessage *m, const char sig[])
{
return strcmp(dbus_message_get_signature(m), sig) == 0;
return spa_streq(dbus_message_get_signature(m), sig);
}
static int set_dbus_property(struct impl *backend,
@ -316,41 +317,41 @@ static void parse_transport_properties_values(struct impl *backend,
switch (dbus_message_iter_get_arg_type(&variant_i)) {
case DBUS_TYPE_STRING:
if (strcmp(key, "RxVolumeControl") == 0 || strcmp(key, "TxVolumeControl") == 0) {
if (spa_streq(key, "RxVolumeControl") || spa_streq(key, "TxVolumeControl")) {
const char *value;
enum hsphfpd_volume_control volume_control;
dbus_message_iter_get_basic(&variant_i, &value);
if (strcmp(value, "none") == 0)
if (spa_streq(value, "none"))
volume_control = HSPHFPD_VOLUME_CONTROL_NONE;
else if (strcmp(value, "local") == 0)
else if (spa_streq(value, "local"))
volume_control = HSPHFPD_VOLUME_CONTROL_LOCAL;
else if (strcmp(value, "remote") == 0)
else if (spa_streq(value, "remote"))
volume_control = HSPHFPD_VOLUME_CONTROL_REMOTE;
else
volume_control = 0;
if (!volume_control)
spa_log_warn(backend->log, NAME": Transport %s received invalid '%s' property value '%s', ignoring", transport_path, key, value);
else if (strcmp(key, "RxVolumeControl") == 0)
else if (spa_streq(key, "RxVolumeControl"))
*rx_volume_control = volume_control;
else if (strcmp(key, "TxVolumeControl") == 0)
else if (spa_streq(key, "TxVolumeControl"))
*tx_volume_control = volume_control;
} else if (strcmp(key, "AirCodec") == 0)
} else if (spa_streq(key, "AirCodec"))
dbus_message_iter_get_basic(&variant_i, air_codec);
break;
case DBUS_TYPE_UINT16:
if (strcmp(key, "MTU") == 0)
if (spa_streq(key, "MTU"))
dbus_message_iter_get_basic(&variant_i, mtu);
else if (strcmp(key, "RxVolumeGain") == 0)
else if (spa_streq(key, "RxVolumeGain"))
dbus_message_iter_get_basic(&variant_i, rx_volume_gain);
else if (strcmp(key, "TxVolumeGain") == 0)
else if (spa_streq(key, "TxVolumeGain"))
dbus_message_iter_get_basic(&variant_i, tx_volume_gain);
break;
case DBUS_TYPE_OBJECT_PATH:
if (strcmp(key, "Endpoint") == 0)
if (spa_streq(key, "Endpoint"))
dbus_message_iter_get_basic(&variant_i, endpoint_path);
break;
}
@ -484,9 +485,9 @@ static DBusHandlerResult audio_agent_get_property(DBusConnection *conn, DBusMess
goto fail;
}
if (strcmp(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ) == 0)
if (spa_streq(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ))
agent_codec = HSPHFP_AGENT_CODEC_PCM;
else if (strcmp(path, HSPHFP_AUDIO_CLIENT_MSBC) == 0)
else if (spa_streq(path, HSPHFP_AUDIO_CLIENT_MSBC))
agent_codec = HSPHFP_AGENT_CODEC_MSBC;
else {
r = dbus_message_new_error(m, DBUS_ERROR_INVALID_ARGS, "Invalid path in method call");
@ -526,9 +527,9 @@ static DBusHandlerResult audio_agent_getall_properties(DBusConnection *conn, DBu
goto fail;
}
if (strcmp(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ) == 0)
if (spa_streq(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ))
agent_codec = HSPHFP_AGENT_CODEC_PCM;
else if (strcmp(path, HSPHFP_AUDIO_CLIENT_MSBC) == 0)
else if (spa_streq(path, HSPHFP_AUDIO_CLIENT_MSBC))
agent_codec = HSPHFP_AGENT_CODEC_MSBC;
else {
r = dbus_message_new_error(m, DBUS_ERROR_INVALID_ARGS, "Invalid path in method call");
@ -599,9 +600,9 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
goto fail;
}
if (strcmp(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ) == 0)
if (spa_streq(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ))
codec = HFP_AUDIO_CODEC_CVSD;
else if (strcmp(path, HSPHFP_AUDIO_CLIENT_MSBC) == 0)
else if (spa_streq(path, HSPHFP_AUDIO_CLIENT_MSBC))
codec = HFP_AUDIO_CODEC_MSBC;
else {
r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "Invalid path");
@ -1013,25 +1014,25 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend,
{
const char *value;
dbus_message_iter_get_basic(&value_i, &value);
if (strcmp(key, "RemoteAddress") == 0)
if (spa_streq(key, "RemoteAddress"))
endpoint->remote_address = strdup(value);
else if (strcmp(key, "LocalAddress") == 0)
else if (spa_streq(key, "LocalAddress"))
endpoint->local_address = strdup(value);
else if (strcmp(key, "Profile") == 0) {
else if (spa_streq(key, "Profile")) {
if (endpoint->profile)
spa_log_warn(backend->log, NAME": Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key);
else if (strcmp(value, "headset") == 0)
else if (spa_streq(value, "headset"))
endpoint->profile = HSPHFPD_PROFILE_HEADSET;
else if (strcmp(value, "handsfree") == 0)
else if (spa_streq(value, "handsfree"))
endpoint->profile = HSPHFPD_PROFILE_HANDSFREE;
else
spa_log_warn(backend->log, NAME": Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value);
} else if (strcmp(key, "Role") == 0) {
} else if (spa_streq(key, "Role")) {
if (endpoint->role)
spa_log_warn(backend->log, NAME": Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key);
else if (strcmp(value, "client") == 0)
else if (spa_streq(value, "client"))
endpoint->role = HSPHFPD_ROLE_CLIENT;
else if (strcmp(value, "gateway") == 0)
else if (spa_streq(value, "gateway"))
endpoint->role = HSPHFPD_ROLE_GATEWAY;
else
spa_log_warn(backend->log, NAME": Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value);
@ -1044,7 +1045,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend,
{
bool value;
dbus_message_iter_get_basic(&value_i, &value);
if (strcmp(key, "Connected") == 0)
if (spa_streq(key, "Connected"))
endpoint->connected = value;
spa_log_trace(backend->log, NAME": %s: %d", key, value);
}
@ -1052,7 +1053,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend,
case DBUS_TYPE_ARRAY:
{
if (strcmp(key, "AudioCodecs") == 0) {
if (spa_streq(key, "AudioCodecs")) {
DBusMessageIter array_i;
const char *value;
@ -1060,9 +1061,9 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend,
dbus_message_iter_recurse(&value_i, &array_i);
while (dbus_message_iter_get_arg_type(&array_i) != DBUS_TYPE_INVALID) {
dbus_message_iter_get_basic(&array_i, &value);
if (strcmp(value, HSPHFP_AIR_CODEC_CVSD) == 0)
if (spa_streq(value, HSPHFP_AIR_CODEC_CVSD))
endpoint->air_codecs |= HFP_AUDIO_CODEC_CVSD;
if (strcmp(value, HSPHFP_AIR_CODEC_MSBC) == 0)
if (spa_streq(value, HSPHFP_AIR_CODEC_MSBC))
endpoint->air_codecs |= HFP_AUDIO_CODEC_MSBC;
dbus_message_iter_next(&array_i);
}
@ -1163,7 +1164,7 @@ static DBusHandlerResult hsphfpd_parse_interfaces(struct impl *backend, DBusMess
dbus_message_iter_get_basic(&iface_i, &interface);
dbus_message_iter_next(&iface_i);
if (strcmp(interface, HSPHFPD_ENDPOINT_INTERFACE) == 0) {
if (spa_streq(interface, HSPHFPD_ENDPOINT_INTERFACE)) {
struct hsphfpd_endpoint *endpoint;
endpoint = endpoint_find(backend, path);
@ -1315,7 +1316,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
sender = dbus_message_get_sender(m);
if (backend->hsphfpd_service_id && strcmp(sender, backend->hsphfpd_service_id) == 0) {
if (backend->hsphfpd_service_id && spa_streq(sender, backend->hsphfpd_service_id)) {
if (dbus_message_is_signal(m, DBUS_INTERFACE_OBJECTMANAGER, "InterfacesAdded")) {
DBusMessageIter arg_i;
@ -1351,7 +1352,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
dbus_message_iter_get_basic(&element_i, &iface);
if (strcmp(iface, HSPHFPD_ENDPOINT_INTERFACE) == 0) {
if (spa_streq(iface, HSPHFPD_ENDPOINT_INTERFACE)) {
struct hsphfpd_endpoint *endpoint;
struct spa_bt_transport *transport = spa_bt_transport_find(backend->monitor, path);
@ -1384,7 +1385,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
path = dbus_message_get_path(m);
if (strcmp(iface, HSPHFPD_ENDPOINT_INTERFACE) == 0) {
if (spa_streq(iface, HSPHFPD_ENDPOINT_INTERFACE)) {
struct hsphfpd_endpoint *endpoint = endpoint_find(backend, path);
if (!endpoint) {
spa_log_warn(backend->log, NAME": Properties changed on unknown endpoint %s", path);
@ -1392,7 +1393,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m,
}
spa_log_debug(backend->log, NAME": Properties changed on endpoint %s", path);
hsphfpd_parse_endpoint_properties(backend, endpoint, &arg_i);
} else if (strcmp(iface, HSPHFPD_AUDIO_TRANSPORT_INTERFACE) == 0) {
} else if (spa_streq(iface, HSPHFPD_AUDIO_TRANSPORT_INTERFACE)) {
struct spa_bt_transport *transport = spa_bt_transport_find_full(backend->monitor,
hsphfpd_cmp_transport_path,
(const void *)path);
@ -1507,7 +1508,7 @@ struct spa_bt_backend *backend_hsphfpd_new(struct spa_bt_monitor *monitor,
backend->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop);
backend->conn = dbus_connection;
if (info && (str = spa_dict_lookup(info, "bluez5.msbc-support")))
backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1;
backend->msbc_supported = spa_streq(str, "true") || atoi(str) == 1;
else
backend->msbc_supported = false;

View file

@ -37,6 +37,7 @@
#include <spa/support/loop.h>
#include <spa/support/dbus.h>
#include <spa/support/plugin.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/utils/json.h>
#include <spa/param/audio/raw.h>
@ -1056,8 +1057,8 @@ static void sco_listen_event(struct spa_source *source)
/* Find transport for local and remote address */
spa_list_for_each_safe(rfcomm, rfcomm_tmp, &backend->rfcomm_list, link) {
if (rfcomm->transport && strcmp(rfcomm->transport->device->address, remote_address) == 0 &&
strcmp(rfcomm->transport->device->adapter->address, local_address) == 0) {
if (rfcomm->transport && spa_streq(rfcomm->transport->device->address, remote_address) &&
spa_streq(rfcomm->transport->device->adapter->address, local_address)) {
t = rfcomm->transport;
break;
}
@ -1421,15 +1422,15 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
handler = dbus_message_get_path(m);
#ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE
if (strcmp(handler, PROFILE_HSP_AG) == 0)
if (spa_streq(handler, PROFILE_HSP_AG))
profile = SPA_BT_PROFILE_HSP_HS;
else if (strcmp(handler, PROFILE_HSP_HS) == 0)
else if (spa_streq(handler, PROFILE_HSP_HS))
profile = SPA_BT_PROFILE_HSP_AG;
#endif
#ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE
if (strcmp(handler, PROFILE_HFP_AG) == 0)
if (spa_streq(handler, PROFILE_HFP_AG))
profile = SPA_BT_PROFILE_HFP_HF;
else if (strcmp(handler, PROFILE_HFP_HF) == 0)
else if (spa_streq(handler, PROFILE_HFP_HF))
profile = SPA_BT_PROFILE_HFP_AG;
#endif
@ -1477,7 +1478,7 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag
spa_list_append(&backend->rfcomm_list, &rfcomm->link);
if (d->settings && (str = spa_dict_lookup(d->settings, "bluez5.msbc-support")))
rfcomm->msbc_support_enabled_in_config = strcmp(str, "true") == 0 || atoi(str) == 1;
rfcomm->msbc_support_enabled_in_config = spa_streq(str, "true") || atoi(str) == 1;
else
rfcomm->msbc_support_enabled_in_config = false;
@ -1560,15 +1561,15 @@ static DBusHandlerResult profile_request_disconnection(DBusConnection *conn, DBu
handler = dbus_message_get_path(m);
#ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE
if (strcmp(handler, PROFILE_HSP_AG) == 0)
if (spa_streq(handler, PROFILE_HSP_AG))
profile = SPA_BT_PROFILE_HSP_HS;
else if (strcmp(handler, PROFILE_HSP_HS) == 0)
else if (spa_streq(handler, PROFILE_HSP_HS))
profile = SPA_BT_PROFILE_HSP_AG;
#endif
#ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE
if (strcmp(handler, PROFILE_HFP_AG) == 0)
if (spa_streq(handler, PROFILE_HFP_AG))
profile = SPA_BT_PROFILE_HFP_HF;
else if (strcmp(handler, PROFILE_HFP_HF) == 0)
else if (spa_streq(handler, PROFILE_HFP_HF))
profile = SPA_BT_PROFILE_HFP_AG;
#endif
@ -1692,8 +1693,8 @@ static int register_profile(struct impl *backend, const char *profile, const cha
dbus_message_iter_append_basic(&it[0], DBUS_TYPE_STRING, &uuid);
dbus_message_iter_open_container(&it[0], DBUS_TYPE_ARRAY, "{sv}", &it[1]);
if (strcmp(uuid, SPA_BT_UUID_HSP_HS) == 0 ||
strcmp(uuid, SPA_BT_UUID_HSP_HS_ALT) == 0) {
if (spa_streq(uuid, SPA_BT_UUID_HSP_HS) ||
spa_streq(uuid, SPA_BT_UUID_HSP_HS_ALT)) {
/* In the headset role, the connection will only be initiated from the remote side */
str = "AutoConnect";
@ -1723,7 +1724,7 @@ static int register_profile(struct impl *backend, const char *profile, const cha
dbus_message_iter_append_basic(&it[3], DBUS_TYPE_UINT16, &version);
dbus_message_iter_close_container(&it[2], &it[3]);
dbus_message_iter_close_container(&it[1], &it[2]);
} else if (strcmp(uuid, SPA_BT_UUID_HFP_AG) == 0) {
} else if (spa_streq(uuid, SPA_BT_UUID_HFP_AG)) {
str = "Features";
/* We announce wideband speech support anyway */
@ -1744,7 +1745,7 @@ static int register_profile(struct impl *backend, const char *profile, const cha
dbus_message_iter_append_basic(&it[3], DBUS_TYPE_UINT16, &version);
dbus_message_iter_close_container(&it[2], &it[3]);
dbus_message_iter_close_container(&it[1], &it[2]);
} else if (strcmp(uuid, SPA_BT_UUID_HFP_HF) == 0) {
} else if (spa_streq(uuid, SPA_BT_UUID_HFP_HF)) {
str = "Features";
/* We announce wideband speech support anyway */

View file

@ -36,6 +36,7 @@
#include <spa/support/loop.h>
#include <spa/support/dbus.h>
#include <spa/support/plugin.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/param/audio/raw.h>
@ -321,12 +322,12 @@ static DBusHandlerResult ofono_audio_card_found(struct impl *backend, char *path
dbus_message_iter_get_basic(&value_i, &value);
if (strcmp(key, "RemoteAddress") == 0) {
if (spa_streq(key, "RemoteAddress")) {
remote_address = value;
} else if (strcmp(key, "LocalAddress") == 0) {
} else if (spa_streq(key, "LocalAddress")) {
local_address = value;
} else if (strcmp(key, "Type") == 0) {
if (strcmp(value, "gateway") == 0)
} else if (spa_streq(key, "Type")) {
if (spa_streq(value, "gateway"))
profile = SPA_BT_PROFILE_HFP_HF;
}
@ -788,7 +789,7 @@ struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
backend->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop);
backend->conn = dbus_connection;
if (info && (str = spa_dict_lookup(info, "bluez5.msbc-support")))
backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1;
backend->msbc_supported = spa_streq(str, "true") || atoi(str) == 1;
else
backend->msbc_supported = false;

View file

@ -46,6 +46,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include "a2dp-codecs.h"
@ -413,7 +414,7 @@ static const struct a2dp_codec *a2dp_endpoint_to_codec(const char *endpoint)
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))
return codec;
}
return NULL;
@ -433,7 +434,7 @@ static int a2dp_endpoint_to_profile(const char *endpoint)
static bool is_a2dp_codec_enabled(struct spa_bt_monitor *monitor, const struct a2dp_codec *codec)
{
if (!monitor->enable_sbc_xq && codec->feature_flag != NULL &&
strcmp(codec->feature_flag, "sbc-xq") == 0)
spa_streq(codec->feature_flag, "sbc-xq"))
return false;
return spa_dict_lookup(&monitor->enabled_codecs, codec->name) != NULL;
@ -505,7 +506,7 @@ static struct spa_bt_adapter *adapter_find(struct spa_bt_monitor *monitor, const
{
struct spa_bt_adapter *d;
spa_list_for_each(d, &monitor->adapter_list, link)
if (strcmp(d->path, path) == 0)
if (spa_streq(d->path, path))
return d;
return NULL;
}
@ -545,15 +546,15 @@ static int adapter_update_props(struct spa_bt_adapter *adapter,
spa_log_debug(monitor->log, "adapter %p: %s=%s", adapter, key, value);
if (strcmp(key, "Alias") == 0) {
if (spa_streq(key, "Alias")) {
free(adapter->alias);
adapter->alias = strdup(value);
}
else if (strcmp(key, "Name") == 0) {
else if (spa_streq(key, "Name")) {
free(adapter->name);
adapter->name = strdup(value);
}
else if (strcmp(key, "Address") == 0) {
else if (spa_streq(key, "Address")) {
free(adapter->address);
adapter->address = strdup(value);
}
@ -565,7 +566,7 @@ static int adapter_update_props(struct spa_bt_adapter *adapter,
spa_log_debug(monitor->log, "adapter %p: %s=%d", adapter, key, value);
if (strcmp(key, "Class") == 0)
if (spa_streq(key, "Class"))
adapter->bluetooth_class = value;
}
@ -576,11 +577,11 @@ static int adapter_update_props(struct spa_bt_adapter *adapter,
spa_log_debug(monitor->log, "adapter %p: %s=%d", adapter, key, value);
if (strcmp(key, "Powered") == 0) {
if (spa_streq(key, "Powered")) {
adapter->powered = value;
}
}
else if (strcmp(key, "UUIDs") == 0) {
else if (spa_streq(key, "UUIDs")) {
DBusMessageIter iter;
if (!check_iter_signature(&it[1], "as"))
@ -645,7 +646,7 @@ struct spa_bt_device *spa_bt_device_find(struct spa_bt_monitor *monitor, const c
{
struct spa_bt_device *d;
spa_list_for_each(d, &monitor->device_list, link)
if (strcmp(d->path, path) == 0)
if (spa_streq(d->path, path))
return d;
return NULL;
}
@ -654,7 +655,7 @@ struct spa_bt_device *spa_bt_device_find_by_address(struct spa_bt_monitor *monit
{
struct spa_bt_device *d;
spa_list_for_each(d, &monitor->device_list, link)
if (strcmp(d->address, remote_address) == 0 && strcmp(d->adapter->address, local_address) == 0)
if (spa_streq(d->address, remote_address) && spa_streq(d->adapter->address, local_address))
return d;
return NULL;
}
@ -1107,19 +1108,19 @@ static int device_update_props(struct spa_bt_device *device,
spa_log_debug(monitor->log, "device %p: %s=%s", device, key, value);
if (strcmp(key, "Alias") == 0) {
if (spa_streq(key, "Alias")) {
free(device->alias);
device->alias = strdup(value);
}
else if (strcmp(key, "Name") == 0) {
else if (spa_streq(key, "Name")) {
free(device->name);
device->name = strdup(value);
}
else if (strcmp(key, "Address") == 0) {
else if (spa_streq(key, "Address")) {
free(device->address);
device->address = strdup(value);
}
else if (strcmp(key, "Adapter") == 0) {
else if (spa_streq(key, "Adapter")) {
free(device->adapter_path);
device->adapter_path = strdup(value);
@ -1128,7 +1129,7 @@ static int device_update_props(struct spa_bt_device *device,
spa_log_warn(monitor->log, "unknown adapter %s", value);
}
}
else if (strcmp(key, "Icon") == 0) {
else if (spa_streq(key, "Icon")) {
free(device->icon);
device->icon = strdup(value);
}
@ -1140,7 +1141,7 @@ static int device_update_props(struct spa_bt_device *device,
spa_log_debug(monitor->log, "device %p: %s=%08x", device, key, value);
if (strcmp(key, "Class") == 0)
if (spa_streq(key, "Class"))
device->bluetooth_class = value;
}
else if (type == DBUS_TYPE_UINT16) {
@ -1150,7 +1151,7 @@ static int device_update_props(struct spa_bt_device *device,
spa_log_debug(monitor->log, "device %p: %s=%d", device, key, value);
if (strcmp(key, "Appearance") == 0)
if (spa_streq(key, "Appearance"))
device->appearance = value;
}
else if (type == DBUS_TYPE_INT16) {
@ -1160,7 +1161,7 @@ static int device_update_props(struct spa_bt_device *device,
spa_log_debug(monitor->log, "device %p: %s=%d", device, key, value);
if (strcmp(key, "RSSI") == 0)
if (spa_streq(key, "RSSI"))
device->RSSI = value;
}
else if (type == DBUS_TYPE_BOOLEAN) {
@ -1170,24 +1171,24 @@ static int device_update_props(struct spa_bt_device *device,
spa_log_debug(monitor->log, "device %p: %s=%d", device, key, value);
if (strcmp(key, "Paired") == 0) {
if (spa_streq(key, "Paired")) {
device->paired = value;
}
else if (strcmp(key, "Trusted") == 0) {
else if (spa_streq(key, "Trusted")) {
device->trusted = value;
}
else if (strcmp(key, "Connected") == 0) {
else if (spa_streq(key, "Connected")) {
device_set_connected(device, value);
}
else if (strcmp(key, "Blocked") == 0) {
else if (spa_streq(key, "Blocked")) {
device->blocked = value;
}
else if (strcmp(key, "ServicesResolved") == 0) {
else if (spa_streq(key, "ServicesResolved")) {
if (value)
spa_bt_device_check_profiles(device, false);
}
}
else if (strcmp(key, "UUIDs") == 0) {
else if (spa_streq(key, "UUIDs")) {
DBusMessageIter iter;
uint32_t prev_profiles = device->profiles;
@ -1232,7 +1233,7 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc
if (!device->adapter->application_registered) {
/* Codec switching not supported: only plain SBC allowed */
return (codec->codec_id == A2DP_CODEC_SBC && strcmp(codec->name, "sbc") == 0);
return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc"));
}
spa_list_for_each(ep, &device->remote_endpoint_list, device_link) {
@ -1285,7 +1286,7 @@ static struct spa_bt_remote_endpoint *device_remote_endpoint_find(struct spa_bt_
{
struct spa_bt_remote_endpoint *ep;
spa_list_for_each(ep, &device->remote_endpoint_list, device_link)
if (strcmp(ep->path, path) == 0)
if (spa_streq(ep->path, path))
return ep;
return NULL;
}
@ -1294,7 +1295,7 @@ static struct spa_bt_remote_endpoint *remote_endpoint_find(struct spa_bt_monitor
{
struct spa_bt_remote_endpoint *ep;
spa_list_for_each(ep, &monitor->remote_endpoint_list, link)
if (strcmp(ep->path, path) == 0)
if (spa_streq(ep->path, path))
return ep;
return NULL;
}
@ -1324,11 +1325,11 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en
spa_log_debug(monitor->log, "remote_endpoint %p: %s=%s", remote_endpoint, key, value);
if (strcmp(key, "UUID") == 0) {
if (spa_streq(key, "UUID")) {
free(remote_endpoint->uuid);
remote_endpoint->uuid = strdup(value);
}
else if (strcmp(key, "Device") == 0) {
else if (spa_streq(key, "Device")) {
struct spa_bt_device *device;
device = spa_bt_device_find(monitor, value);
if (device == NULL)
@ -1351,7 +1352,7 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en
spa_log_debug(monitor->log, "remote_endpoint %p: %s=%d", remote_endpoint, key, value);
if (strcmp(key, "DelayReporting") == 0) {
if (spa_streq(key, "DelayReporting")) {
remote_endpoint->delay_reporting = value;
}
}
@ -1362,11 +1363,11 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en
spa_log_debug(monitor->log, "remote_endpoint %p: %s=%02x", remote_endpoint, key, value);
if (strcmp(key, "Codec") == 0) {
if (spa_streq(key, "Codec")) {
remote_endpoint->codec = value;
}
}
else if (strcmp(key, "Capabilities") == 0) {
else if (spa_streq(key, "Capabilities")) {
DBusMessageIter iter;
uint8_t *value;
int i, len;
@ -1436,7 +1437,7 @@ struct spa_bt_transport *spa_bt_transport_find(struct spa_bt_monitor *monitor, c
{
struct spa_bt_transport *t;
spa_list_for_each(t, &monitor->transport_list, link)
if (strcmp(t->path, path) == 0)
if (spa_streq(t->path, path))
return t;
return NULL;
}
@ -1816,7 +1817,7 @@ static int transport_update_props(struct spa_bt_transport *transport,
spa_log_debug(monitor->log, "transport %p: %s=%s", transport, key, value);
if (strcmp(key, "UUID") == 0) {
if (spa_streq(key, "UUID")) {
switch (spa_bt_profile_from_uuid(value)) {
case SPA_BT_PROFILE_A2DP_SOURCE:
transport->profile = SPA_BT_PROFILE_A2DP_SINK;
@ -1829,16 +1830,16 @@ static int transport_update_props(struct spa_bt_transport *transport,
break;
}
}
else if (strcmp(key, "State") == 0) {
else if (spa_streq(key, "State")) {
spa_bt_transport_set_state(transport, spa_bt_transport_state_from_string(value));
}
else if (strcmp(key, "Device") == 0) {
else if (spa_streq(key, "Device")) {
transport->device = spa_bt_device_find(monitor, value);
if (transport->device == NULL)
spa_log_warn(monitor->log, "could not find device %s", value);
}
}
else if (strcmp(key, "Codec") == 0) {
else if (spa_streq(key, "Codec")) {
uint8_t value;
if (type != DBUS_TYPE_BYTE)
@ -1849,7 +1850,7 @@ static int transport_update_props(struct spa_bt_transport *transport,
transport->codec = value;
}
else if (strcmp(key, "Configuration") == 0) {
else if (spa_streq(key, "Configuration")) {
DBusMessageIter iter;
uint8_t *value;
int i, len;
@ -1873,7 +1874,7 @@ static int transport_update_props(struct spa_bt_transport *transport,
transport->configuration_len = len;
}
}
else if (strcmp(key, "Volume") == 0) {
else if (spa_streq(key, "Volume")) {
uint16_t value;
struct spa_bt_transport_volume * t_volume;
@ -1898,7 +1899,7 @@ static int transport_update_props(struct spa_bt_transport *transport,
else
spa_bt_transport_volume_changed(transport);
}
else if (strcmp(key, "Delay") == 0) {
else if (spa_streq(key, "Delay")) {
uint16_t value;
if (type != DBUS_TYPE_UINT16)
@ -2011,7 +2012,7 @@ static int transport_acquire(void *data, bool optional)
m = NULL;
if (r == NULL) {
if (optional && strcmp(err.name, "org.bluez.Error.NotAvailable") == 0) {
if (optional && spa_streq(err.name, "org.bluez.Error.NotAvailable")) {
spa_log_info(monitor->log, "Failed optional acquire of unavailable transport %s",
transport->path);
}
@ -2851,7 +2852,7 @@ static int adapter_register_endpoints(struct spa_bt_adapter *a)
if (!is_a2dp_codec_enabled(monitor, codec))
continue;
if (!(codec->codec_id == A2DP_CODEC_SBC && strcmp(codec->name, "sbc") == 0))
if (!(codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc")))
continue;
if ((err = bluez_register_endpoint(monitor, a->path,
@ -3125,7 +3126,7 @@ static void interface_added(struct spa_bt_monitor *monitor,
{
spa_log_debug(monitor->log, "Found object %s, interface %s", object_path, interface_name);
if (strcmp(interface_name, BLUEZ_ADAPTER_INTERFACE) == 0) {
if (spa_streq(interface_name, BLUEZ_ADAPTER_INTERFACE)) {
struct spa_bt_adapter *a;
a = adapter_find(monitor, object_path);
@ -3139,13 +3140,13 @@ static void interface_added(struct spa_bt_monitor *monitor,
adapter_update_props(a, props_iter, NULL);
adapter_register_application(a);
}
else if (strcmp(interface_name, BLUEZ_PROFILE_MANAGER_INTERFACE) == 0) {
else if (spa_streq(interface_name, BLUEZ_PROFILE_MANAGER_INTERFACE)) {
if (!monitor->backend_ofono_registered && !monitor->backend_hsphfpd_registered) {
spa_bt_backend_register_profiles(monitor->backend_native);
monitor->backend_native_registered = true;
}
}
else if (strcmp(interface_name, BLUEZ_DEVICE_INTERFACE) == 0) {
else if (spa_streq(interface_name, BLUEZ_DEVICE_INTERFACE)) {
struct spa_bt_device *d;
d = spa_bt_device_find(monitor, object_path);
@ -3171,7 +3172,7 @@ static void interface_added(struct spa_bt_monitor *monitor,
d->reconnect_state = BT_DEVICE_RECONNECT_INIT;
device_start_timer(d);
}
else if (strcmp(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE) == 0) {
else if (spa_streq(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) {
struct spa_bt_remote_endpoint *ep;
struct spa_bt_device *d;
@ -3233,17 +3234,17 @@ static void interfaces_removed(struct spa_bt_monitor *monitor, DBusMessageIter *
spa_log_debug(monitor->log, "Found object %s, interface %s", object_path, interface_name);
if (strcmp(interface_name, BLUEZ_DEVICE_INTERFACE) == 0) {
if (spa_streq(interface_name, BLUEZ_DEVICE_INTERFACE)) {
struct spa_bt_device *d;
d = spa_bt_device_find(monitor, object_path);
if (d != NULL)
device_free(d);
} else if (strcmp(interface_name, BLUEZ_ADAPTER_INTERFACE) == 0) {
} else if (spa_streq(interface_name, BLUEZ_ADAPTER_INTERFACE)) {
struct spa_bt_adapter *a;
a = adapter_find(monitor, object_path);
if (a != NULL)
adapter_free(a);
} else if (strcmp(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE) == 0) {
} else if (spa_streq(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) {
struct spa_bt_remote_endpoint *ep;
ep = remote_endpoint_find(monitor, object_path);
if (ep != NULL) {
@ -3339,7 +3340,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
goto fail;
}
if (strcmp(name, BLUEZ_SERVICE) == 0) {
if (spa_streq(name, BLUEZ_SERVICE)) {
bool has_old_owner = old_owner && *old_owner;
bool has_new_owner = new_owner && *new_owner;
@ -3374,7 +3375,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
spa_log_debug(monitor->log, "Bluetooth daemon appeared");
get_managed_objects(monitor);
}
} else if (strcmp(name, OFONO_SERVICE) == 0 && monitor->backend_ofono) {
} else if (spa_streq(name, OFONO_SERVICE) && monitor->backend_ofono) {
if (old_owner && *old_owner) {
spa_log_debug(monitor->log, "oFono daemon disappeared");
monitor->backend_ofono_registered = false;
@ -3395,7 +3396,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
monitor->backend_native_registered = true;
}
}
} else if (strcmp(name, HSPHFPD_SERVICE) == 0 && monitor->backend_hsphfpd) {
} else if (spa_streq(name, HSPHFPD_SERVICE) && monitor->backend_hsphfpd) {
if (old_owner && *old_owner) {
spa_log_debug(monitor->log, "hsphfpd daemon disappeared");
spa_bt_backend_unregistered(monitor->backend_hsphfpd);
@ -3464,7 +3465,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
dbus_message_iter_next(&it[0]);
dbus_message_iter_recurse(&it[0], &it[1]);
if (strcmp(iface, BLUEZ_ADAPTER_INTERFACE) == 0) {
if (spa_streq(iface, BLUEZ_ADAPTER_INTERFACE)) {
struct spa_bt_adapter *a;
a = adapter_find(monitor, path);
@ -3477,7 +3478,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
adapter_update_props(a, &it[1], NULL);
}
else if (strcmp(iface, BLUEZ_DEVICE_INTERFACE) == 0) {
else if (spa_streq(iface, BLUEZ_DEVICE_INTERFACE)) {
struct spa_bt_device *d;
d = spa_bt_device_find(monitor, path);
@ -3490,7 +3491,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
device_update_props(d, &it[1], NULL);
}
else if (strcmp(iface, BLUEZ_MEDIA_ENDPOINT_INTERFACE) == 0) {
else if (spa_streq(iface, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) {
struct spa_bt_remote_endpoint *ep;
struct spa_bt_device *d;
@ -3508,7 +3509,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
if (d)
spa_bt_device_emit_profiles_changed(d, d->profiles, d->connected_profiles);
}
else if (strcmp(iface, BLUEZ_MEDIA_TRANSPORT_INTERFACE) == 0) {
else if (spa_streq(iface, BLUEZ_MEDIA_TRANSPORT_INTERFACE)) {
struct spa_bt_transport *transport;
transport = spa_bt_transport_find(monitor, path);
@ -3631,7 +3632,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct spa_bt_monitor *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Device))
*interface = &this->device;
else
return -ENOENT;
@ -3723,17 +3724,17 @@ int spa_bt_profiles_from_json_array(const char *str)
return -EINVAL;
while (spa_json_get_string(&it_array, role_name, sizeof(role_name)) > 0) {
if (strcmp(role_name, "hsp_hs") == 0) {
if (spa_streq(role_name, "hsp_hs")) {
profiles |= SPA_BT_PROFILE_HSP_HS;
} else if (strcmp(role_name, "hsp_ag") == 0) {
} else if (spa_streq(role_name, "hsp_ag")) {
profiles |= SPA_BT_PROFILE_HSP_AG;
} else if (strcmp(role_name, "hfp_hf") == 0) {
} else if (spa_streq(role_name, "hfp_hf")) {
profiles |= SPA_BT_PROFILE_HFP_HF;
} else if (strcmp(role_name, "hfp_ag") == 0) {
} else if (spa_streq(role_name, "hfp_ag")) {
profiles |= SPA_BT_PROFILE_HFP_AG;
} else if (strcmp(role_name, "a2dp_sink") == 0) {
} else if (spa_streq(role_name, "a2dp_sink")) {
profiles |= SPA_BT_PROFILE_A2DP_SINK;
} else if (strcmp(role_name, "a2dp_source") == 0) {
} else if (spa_streq(role_name, "a2dp_source")) {
profiles |= SPA_BT_PROFILE_A2DP_SOURCE;
}
}
@ -3875,7 +3876,7 @@ impl_init(const struct spa_handle_factory *factory,
uint32_t tmp;
if ((str = spa_dict_lookup(info, "api.bluez5.connection-info")) != NULL &&
(strcmp(str, "true") == 0 || atoi(str)))
(spa_streq(str, "true") || atoi(str)))
this->connection_info_supported = true;
if ((str = spa_dict_lookup(info, "bluez5.default.rate")) != NULL &&
@ -3887,7 +3888,7 @@ impl_init(const struct spa_handle_factory *factory,
this->default_audio_info.channels = tmp;
if ((str = spa_dict_lookup(info, "bluez5.sbc-xq-support")) != NULL &&
(strcmp(str, "true") == 0 || atoi(str)))
(spa_streq(str, "true") || atoi(str)))
this->enable_sbc_xq = true;
}

View file

@ -34,6 +34,7 @@
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
@ -980,7 +981,7 @@ static void set_initial_profile(struct impl *this)
const char *str;
if (this->bt_dev->settings != NULL) {
str = spa_dict_lookup(this->bt_dev->settings, "device.profile");
if (str != NULL && strcmp(str, "headset-head-unit") == 0 && find_hsp_hfp_profile(this))
if (str != NULL && spa_streq(str, "headset-head-unit") && find_hsp_hfp_profile(this))
return;
}
@ -1806,7 +1807,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void
this = (struct impl *) handle;
if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0)
if (spa_streq(type, SPA_TYPE_INTERFACE_Device))
*interface = &this->device;
else
return -ENOENT;

View file

@ -35,6 +35,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -1139,7 +1140,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

@ -37,6 +37,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -1198,7 +1199,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;