diff --git a/src/adapter.c b/src/adapter.c
index 1baf957..7cc11b6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
const char *dest)
{
struct btd_device *device;
- GSList *l;
+ GSList *list;
if (!adapter)
return NULL;
- l = g_slist_find_custom(adapter->devices, dest,
- (GCompareFunc) device_address_cmp);
- if (!l)
+ list = g_slist_find_custom(adapter->devices, dest, device_address_cmp);
+ if (!list)
return NULL;
- device = l->data;
+ device = list->data;
return device;
}
return TRUE;
}
-static gint device_path_cmp(struct btd_device *device, const char *path)
+static gint device_path_cmp(gconstpointer a, gconstpointer b)
{
+ const struct btd_device *device = a;
+ const char *path = b;
const char *dev_path = device_get_path(device);
return strcasecmp(dev_path, path);
struct btd_adapter *adapter = user_data;
struct btd_device *device;
const char *path;
- GSList *l;
+ GSList *list;
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID) == FALSE)
return btd_error_invalid_args(msg);
- l = g_slist_find_custom(adapter->devices,
- path, (GCompareFunc) device_path_cmp);
- if (!l)
+ list = g_slist_find_custom(adapter->devices, path, device_path_cmp);
+ if (!list)
return btd_error_does_not_exist(msg);
- device = l->data;
+ device = list->data;
device_set_temporary(device, TRUE);
}
device_request_disconnect(device, msg);
+
return NULL;
}
GKeyFile *key_file;
struct link_key_info *key_info;
struct smp_ltk_info *ltk_info;
- GSList *l;
+ GSList *list;
if (entry->d_type != DT_DIR || bachk(entry->d_name) < 0)
continue;
if (ltk_info)
ltks.keys = g_slist_append(ltks.keys, ltk_info);
- l = g_slist_find_custom(adapter->devices, entry->d_name,
- (GCompareFunc) device_address_cmp);
- if (l) {
- device = l->data;
+ list = g_slist_find_custom(adapter->devices, entry->d_name,
+ device_address_cmp);
+ if (list) {
+ device = list->data;
goto device_exist;
}
/* TODO: register services from pre-loaded list of primaries */
- l = device_get_uuids(device);
- if (l)
- device_probe_profiles(device, l);
+ list = device_get_uuids(device);
+ if (list)
+ device_probe_profiles(device, list);
device_exist:
if (key_info || ltk_info) {
diff --git a/src/device.c b/src/device.c
index c65a45d..74bf421 100644
--- a/src/device.c
+++ b/src/device.c
btd_device_unref(device);
}
-gint device_address_cmp(struct btd_device *device, const char *address)
+gint device_address_cmp(gconstpointer a, gconstpointer b)
{
+ const struct btd_device *device = a;
+ const char *address = b;
char addr[18];
ba2str(&device->bdaddr, addr);
return strcasecmp(addr, address);
}
-gint device_bdaddr_cmp(struct btd_device *device, bdaddr_t *bdaddr)
+gint device_bdaddr_cmp(gconstpointer a, gconstpointer b)
{
+ const struct btd_device *device = a;
+ const bdaddr_t *bdaddr = b;
+
return bacmp(&device->bdaddr, bdaddr);
}
return &device->bdaddr;
}
-const char *device_get_path(struct btd_device *device)
+const char *device_get_path(const struct btd_device *device)
{
if (!device)
return NULL;
diff --git a/src/device.h b/src/device.h
index 96e81f0..5e1b8c0 100644
--- a/src/device.h
+++ b/src/device.h
uint16_t btd_device_get_product(struct btd_device *device);
uint16_t btd_device_get_version(struct btd_device *device);
void device_remove(struct btd_device *device, gboolean remove_stored);
-gint device_address_cmp(struct btd_device *device, const char *address);
-gint device_bdaddr_cmp(struct btd_device *device, bdaddr_t *bdaddr);
+gint device_address_cmp(gconstpointer a, gconstpointer b);
+gint device_bdaddr_cmp(gconstpointer a, gconstpointer b);
GSList *device_get_uuids(struct btd_device *device);
void device_probe_profiles(struct btd_device *device, GSList *profiles);
const sdp_record_t *btd_device_get_record(struct btd_device *device,
void device_remove_profile(gpointer a, gpointer b);
struct btd_adapter *device_get_adapter(struct btd_device *device);
const bdaddr_t *device_get_address(struct btd_device *device);
-const char *device_get_path(struct btd_device *device);
+const char *device_get_path(const struct btd_device *device);
gboolean device_is_bredr(struct btd_device *device);
gboolean device_is_le(struct btd_device *device);
gboolean device_is_temporary(struct btd_device *device);