Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCHv2 1/2] android/gatt: Initialize includes queue
@ 2014-11-06 12:57 Marcin Kraglak
  2014-11-06 12:57 ` [PATCHv2 2/2] android/gatt: Search included services in Secondary Services Marcin Kraglak
  2014-11-06 15:18 ` [PATCHv2 1/2] android/gatt: Initialize includes queue Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Marcin Kraglak @ 2014-11-06 12:57 UTC (permalink / raw)
  To: linux-bluetooth

Initialize included queue even if service is Secondary Service.
---
 android/gatt.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 7cf612f..6b57145 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -318,8 +318,7 @@ static void destroy_service(void *data)
 	 * So we need to free service memory only once but we need to destroy
 	 * two queues
 	 */
-	if (srvc->primary)
-		queue_destroy(srvc->included, NULL);
+	queue_destroy(srvc->included, NULL);
 
 	free(srvc);
 }
@@ -1081,6 +1080,14 @@ static struct service *create_service(uint8_t id, bool primary, char *uuid,
 		return NULL;
 	}
 
+	s->included = queue_new();
+	if (!s->included) {
+		error("gatt: Cannot allocate memory for included queue");
+		queue_destroy(s->chars, NULL);
+		free(s);
+		return NULL;
+	}
+
 	if (bt_string_to_uuid(&s->id.uuid, uuid) < 0) {
 		error("gatt: Cannot convert string to uuid");
 		queue_destroy(s->chars, NULL);
@@ -1092,20 +1099,10 @@ static struct service *create_service(uint8_t id, bool primary, char *uuid,
 
 	/* Put primary service to our local list */
 	s->primary = primary;
-	if (s->primary) {
+	if (s->primary)
 		memcpy(&s->prim, data, sizeof(s->prim));
-	} else {
+	else
 		memcpy(&s->incl, data, sizeof(s->incl));
-		return s;
-	}
-
-	/* For primary service allocate queue for included services */
-	s->included = queue_new();
-	if (!s->included) {
-		queue_destroy(s->chars, NULL);
-		free(s);
-		return NULL;
-	}
 
 	return s;
 }
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-06 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 12:57 [PATCHv2 1/2] android/gatt: Initialize includes queue Marcin Kraglak
2014-11-06 12:57 ` [PATCHv2 2/2] android/gatt: Search included services in Secondary Services Marcin Kraglak
2014-11-06 15:18 ` [PATCHv2 1/2] android/gatt: Initialize includes queue Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox