[PATCH 1/9] unit/test-gatt: Use one generic search callback

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

 



In these callbacks only success is verified, so there is no need to
duplicate them.
---
 unit/test-gatt.c | 34 +++++++---------------------------
 1 file changed, 7 insertions(+), 27 deletions(-)

diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 27471ea..f343fe6 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -259,29 +259,7 @@ static struct context *create_context(uint16_t mtu, gconstpointer data)
 	return context;
 }
 
-static void primary_cb(bool success, uint8_t att_ecode,
-						struct bt_gatt_result *result,
-						void *user_data)
-{
-	struct context *context = user_data;
-
-	g_assert(success);
-
-	context_quit(context);
-}
-
-static void characteristic_cb(bool success, uint8_t att_ecode,
-						struct bt_gatt_result *result,
-						void *user_data)
-{
-	struct context *context = user_data;
-
-	g_assert(success);
-
-	context_quit(context);
-}
-
-static void included_cb(bool success, uint8_t att_ecode,
+static void generic_search_cb(bool success, uint8_t att_ecode,
 						struct bt_gatt_result *result,
 						void *user_data)
 {
@@ -328,7 +306,8 @@ static void test_search_primary(gconstpointer data)
 	const struct test_data *test_data = data;
 
 	bt_gatt_discover_all_primary_services(context->att, test_data->uuid,
-						primary_cb, context, NULL);
+							generic_search_cb,
+							context, NULL);
 
 	execute_context(context);
 }
@@ -338,7 +317,8 @@ static void test_search_included(gconstpointer data)
 	struct context *context = create_context(512, data);
 
 	bt_gatt_discover_included_services(context->att, 0x0001, 0xffff,
-						included_cb, context, NULL);
+							generic_search_cb,
+							context, NULL);
 
 	execute_context(context);
 }
@@ -348,8 +328,8 @@ static void test_search_chars(gconstpointer data)
 	struct context *context = create_context(512, data);
 
 	g_assert(bt_gatt_discover_characteristics(context->att, 0x0010, 0x0020,
-						characteristic_cb, context,
-						NULL));
+							generic_search_cb,
+							context, NULL));
 
 	execute_context(context);
 }
-- 
1.9.3

--
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