Diff between bf7446cbcf1be81c6410fc02b2649ea1a12e2700 and 3f2d53c64e704a942940169555e956a578cc4f04

Changed Files

File Additions Deletions Status
src/adapter.c +20 -19 modified
src/device.c +8 -3 modified
src/device.h +3 -3 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index 1baf957..7cc11b6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -713,17 +713,16 @@ struct btd_device *adapter_find_device(struct btd_adapter *adapter,
 							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;
 }
@@ -2062,8 +2061,10 @@ static gboolean property_get_modalias(const GDBusPropertyTable *property,
 	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);
@@ -2075,18 +2076,17 @@ static DBusMessage *remove_device(DBusConnection *conn,
 	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);
 
@@ -2096,6 +2096,7 @@ static DBusMessage *remove_device(DBusConnection *conn,
 	}
 
 	device_request_disconnect(device, msg);
+
 	return NULL;
 }
 
@@ -2432,7 +2433,7 @@ static void load_devices(struct btd_adapter *adapter)
 		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;
@@ -2451,10 +2452,10 @@ static void load_devices(struct btd_adapter *adapter)
 		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;
 		}
 
@@ -2468,9 +2469,9 @@ static void load_devices(struct btd_adapter *adapter)
 
 		/* 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
@@ -2175,16 +2175,21 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
 	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);
 }
 
@@ -3333,7 +3338,7 @@ const bdaddr_t *device_get_address(struct btd_device *device)
 	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
@@ -42,8 +42,8 @@ uint16_t btd_device_get_vendor_src(struct btd_device *device);
 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,
@@ -59,7 +59,7 @@ void device_probe_profile(gpointer a, gpointer b);
 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);