[PATCH 10/10] android/gatt: Avoid copying pointers in matching functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This removes casting void* to struct pointers when there is no need to
do so (pointer comparison).
---
 android/gatt.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index cd0825a..3076a02 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -350,9 +350,8 @@ static struct gatt_app *find_app_by_id(int32_t id)
 static bool match_device_by_bdaddr(const void *data, const void *user_data)
 {
 	const struct gatt_device *dev = data;
-	const bdaddr_t *addr = user_data;
 
-	return !bacmp(&dev->bdaddr, addr);
+	return !bacmp(&dev->bdaddr, user_data);
 }
 
 static bool match_device_by_state(const void *data, const void *user_data)
@@ -408,17 +407,15 @@ static struct app_connection *find_connection_by_id(int32_t conn_id)
 static bool match_connection_by_device(const void *data, const void *user_data)
 {
 	const struct app_connection *conn = data;
-	const struct gatt_device *dev = user_data;
 
-	return conn->device == dev;
+	return conn->device == user_data;
 }
 
 static bool match_connection_by_app(const void *data, const void *user_data)
 {
 	const struct app_connection *conn = data;
-	const struct gatt_app *app = user_data;
 
-	return conn->app == app;
+	return conn->app == user_data;
 }
 
 static struct gatt_device *find_device_by_addr(const bdaddr_t *addr)
@@ -469,9 +466,8 @@ static bool match_srvc_by_bt_uuid(const void *data, const void *user_data)
 static bool match_srvc_by_range(const void *data, const void *user_data)
 {
 	const struct service *srvc = data;
-	const struct att_range *range = user_data;
 
-	return !memcmp(&srvc->prim.range, range, sizeof(srvc->prim.range));
+	return !memcmp(&srvc->prim.range, user_data, sizeof(srvc->prim.range));
 }
 
 static bool match_char_by_higher_inst_id(const void *data,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux