Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/3] Update gatt_service_add size assert for dealing with 128-bit uuids
@ 2013-07-29 18:42 Dirk-Jan C. Binnema
  2013-07-29 18:42 ` [PATCH 2/3] Rename GATT_OPT_CHR_UUID into GATT_OPT_CHR_UUID16 Dirk-Jan C. Binnema
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dirk-Jan C. Binnema @ 2013-07-29 18:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dirk-Jan C. Binnema

From: "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>

To paraphrase Anderson Lizardo: "h" was overflowing for 128-bit services
because the handle is incremented after each attribute is added so at the
end we had: 0xffff + 1 == 0 (h is uint16_t).

As it seems more complex to try to remove the overflow without
affecting the logic too much, we update the assertion.
---
 attrib/gatt-service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index 4b02d39..1b84c89 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
@@ -341,7 +341,7 @@ gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
 	}
 
 	g_assert(size < USHRT_MAX);
-	g_assert(h - start_handle == (uint16_t) size);
+	g_assert(h == 0 || (h - start_handle == (uint16_t) size));
 	g_slist_free_full(chrs, free_gatt_info);
 
 	return TRUE;
-- 
1.8.1.4


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

end of thread, other threads:[~2013-07-30 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-29 18:42 [PATCH 1/3] Update gatt_service_add size assert for dealing with 128-bit uuids Dirk-Jan C. Binnema
2013-07-29 18:42 ` [PATCH 2/3] Rename GATT_OPT_CHR_UUID into GATT_OPT_CHR_UUID16 Dirk-Jan C. Binnema
2013-07-29 18:42 ` [PATCH 3/3] Add support for 128-bit characteristic uuids in gatt_service_add Dirk-Jan C. Binnema
2013-07-30 11:28 ` [PATCH 1/3] Update gatt_service_add size assert for dealing with 128-bit uuids Johan Hedberg

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