Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage
@ 2013-03-28 15:39 Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 01/16] attrib: Simplify boolean tests Jefferson Delfes
                   ` (16 more replies)
  0 siblings, 17 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There are some places that we don't need to use GLib date types. For instance
local variables, fields that dont't go through GLib or return vars.
That patch series do some atomic changes over attrib/gattrib for this purpose.

More changes are coming over attrib/ dir in next days.

Jefferson Delfes (16):
  attrib: Simplify boolean tests
  attrib: Change GAttrib->stale type from gboolean
  attrib: Change command->sent type from gboolean
  attrib: Change is_response return type from gboolean
  attrib: Change match_event return type from gboolean
  attrib: Change g_attrib_set_destroy_function return type
  attrib: Change g_attrib_cancel/_all return type
  attrib: Change g_attrib_unregister/_all return type
  attrib: Change g_attrib_set_debug return type from gboolean
  attrib: Change g_attrib_set_mtu return type from gboolean
  attrib: Change g_attrib_is_encrypted return type from gboolean
  attrib: Change command->opcode type from guint8
  attrib: Change event->handle type from guint16
  attrib: Change command->id type from guint
  attrib: Change event->id type from guint
  attrib: Change command->pdu pointer type from guint8

 attrib/gatt.c        |   5 +-
 attrib/gattrib.c     | 129 ++++++++++++++++++++++++++-------------------------
 attrib/gattrib.h     |  28 +++++------
 attrib/gatttool.c    |   9 ++--
 attrib/interactive.c |   1 +
 attrib/utils.c       |   1 +
 src/attrib-server.c  |   2 +-
 7 files changed, 90 insertions(+), 85 deletions(-)

-- 
1.8.2


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

* [PATCH BlueZ 01/16] attrib: Simplify boolean tests
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Remove unnecessary TRUE/FALSE in boolean tests.
---
 attrib/gatt.c     | 4 ++--
 attrib/gattrib.c  | 6 +++---
 attrib/gatttool.c | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index 44d3eb6..a7cb8f7 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -86,7 +86,7 @@ static struct included_discovery *isd_ref(struct included_discovery *isd)
 
 static void isd_unref(struct included_discovery *isd)
 {
-	if (g_atomic_int_dec_and_test(&isd->refs) == FALSE)
+	if (!g_atomic_int_dec_and_test(&isd->refs))
 		return;
 
 	if (isd->err)
@@ -581,7 +581,7 @@ static void read_long_destroy(gpointer user_data)
 {
 	struct read_long_data *long_read = user_data;
 
-	if (g_atomic_int_dec_and_test(&long_read->ref) == FALSE)
+	if (!g_atomic_int_dec_and_test(&long_read->ref))
 		return;
 
 	if (long_read->buffer != NULL)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 01c19f9..e8e1c2b 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -228,7 +228,7 @@ void g_attrib_unref(GAttrib *attrib)
 
 	DBG("%p: ref=%d", attrib, attrib->refs);
 
-	if (ret == FALSE)
+	if (!ret)
 		return;
 
 	attrib_destroy(attrib);
@@ -369,7 +369,7 @@ static gboolean match_event(struct event *evt, const uint8_t *pdu, gsize len)
 	if (evt->expected == GATTRIB_ALL_EVENTS)
 		return TRUE;
 
-	if (is_response(pdu[0]) == FALSE && evt->expected == GATTRIB_ALL_REQS)
+	if (!is_response(pdu[0]) && evt->expected == GATTRIB_ALL_REQS)
 		return TRUE;
 
 	if (evt->expected == pdu[0] && evt->handle == GATTRIB_ALL_HANDLES)
@@ -420,7 +420,7 @@ static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
 			evt->func(buf, len, evt->user_data);
 	}
 
-	if (is_response(buf[0]) == FALSE)
+	if (!is_response(buf[0]))
 		return TRUE;
 
 	if (attrib->timeout_watch > 0) {
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 29e3261..6525ebc 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -248,7 +248,7 @@ static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -378,7 +378,7 @@ static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("Characteristic value was written successfully\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -452,7 +452,7 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	att_data_list_free(list);
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -573,7 +573,7 @@ int main(int argc, char *argv[])
 	g_option_context_add_group(context, char_rw_group);
 	g_option_group_add_entries(char_rw_group, char_rw_options);
 
-	if (g_option_context_parse(context, &argc, &argv, &gerr) == FALSE) {
+	if (!g_option_context_parse(context, &argc, &argv, &gerr)) {
 		g_printerr("%s\n", gerr->message);
 		g_error_free(gerr);
 	}
-- 
1.8.2


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

* [PATCH BlueZ 02/16] attrib: Change GAttrib->stale type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 01/16] attrib: Simplify boolean tests Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 03/16] attrib: Change command->sent " Jefferson Delfes
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to GAttrib->stale be gboolean.
---
 attrib/gattrib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e8e1c2b..88bfc97 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -27,6 +27,7 @@
 #endif
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <glib.h>
 
@@ -56,7 +57,7 @@ struct _GAttrib {
 	guint next_cmd_id;
 	GDestroyNotify destroy;
 	gpointer destroy_user_data;
-	gboolean stale;
+	bool stale;
 };
 
 struct command {
@@ -277,7 +278,7 @@ static gboolean disconnect_timeout(gpointer data)
 	}
 
 done:
-	attrib->stale = TRUE;
+	attrib->stale = true;
 
 	g_attrib_unref(attrib);
 
-- 
1.8.2


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

* [PATCH BlueZ 03/16] attrib: Change command->sent type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 01/16] attrib: Simplify boolean tests Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 04/16] attrib: Change is_response return " Jefferson Delfes
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to command->sent be gboolean.
---
 attrib/gattrib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 88bfc97..bd8e380 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -66,7 +66,7 @@ struct command {
 	guint8 *pdu;
 	guint16 len;
 	guint8 expected;
-	gboolean sent;
+	bool sent;
 	GAttribResultFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
@@ -335,7 +335,7 @@ static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
 		return TRUE;
 	}
 
-	cmd->sent = TRUE;
+	cmd->sent = true;
 
 	if (attrib->timeout_watch == 0)
 		attrib->timeout_watch = g_timeout_add_seconds(GATT_TIMEOUT,
-- 
1.8.2


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

* [PATCH BlueZ 04/16] attrib: Change is_response return type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (2 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 03/16] attrib: Change command->sent " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 05/16] attrib: Change match_event " Jefferson Delfes
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean as return type of is_response.
---
 attrib/gattrib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index bd8e380..9470457 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -124,7 +124,7 @@ static guint8 opcode2expected(guint8 opcode)
 	return 0;
 }
 
-static gboolean is_response(guint8 opcode)
+static bool is_response(guint8 opcode)
 {
 	switch (opcode) {
 	case ATT_OP_ERROR:
@@ -140,10 +140,10 @@ static gboolean is_response(guint8 opcode)
 	case ATT_OP_PREP_WRITE_RESP:
 	case ATT_OP_EXEC_WRITE_RESP:
 	case ATT_OP_HANDLE_CNF:
-		return TRUE;
+		return true;
 	}
 
-	return FALSE;
+	return false;
 }
 
 GAttrib *g_attrib_ref(GAttrib *attrib)
-- 
1.8.2


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

* [PATCH BlueZ 05/16] attrib: Change match_event return type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (3 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 04/16] attrib: Change is_response return " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean as return type of match_event.
---
 attrib/gattrib.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 9470457..c59d5f5 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -363,28 +363,28 @@ static void wake_up_sender(struct _GAttrib *attrib)
 				can_write_data, attrib, destroy_sender);
 }
 
-static gboolean match_event(struct event *evt, const uint8_t *pdu, gsize len)
+static bool match_event(struct event *evt, const uint8_t *pdu, gsize len)
 {
 	guint16 handle;
 
 	if (evt->expected == GATTRIB_ALL_EVENTS)
-		return TRUE;
+		return true;
 
 	if (!is_response(pdu[0]) && evt->expected == GATTRIB_ALL_REQS)
-		return TRUE;
+		return true;
 
 	if (evt->expected == pdu[0] && evt->handle == GATTRIB_ALL_HANDLES)
-		return TRUE;
+		return true;
 
 	if (len < 3)
-		return FALSE;
+		return false;
 
 	handle = att_get_u16(&pdu[1]);
 
 	if (evt->expected == pdu[0] && evt->handle == handle)
-		return TRUE;
+		return true;
 
-	return FALSE;
+	return false;
 }
 
 static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
-- 
1.8.2


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

* [PATCH BlueZ 06/16] attrib: Change g_attrib_set_destroy_function return type
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (4 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 05/16] attrib: Change match_event " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

The return type from g_attrib_set_destroy_function don't need to be
gboolean, it can be standard bool type.
That change implies change in its signature, which requires stdbool.h to
be included where attrib/gattrib.h is included.
---
 attrib/gatt.c        | 1 +
 attrib/gattrib.c     | 8 ++++----
 attrib/gattrib.h     | 4 ++--
 attrib/gatttool.c    | 1 +
 attrib/interactive.c | 1 +
 attrib/utils.c       | 1 +
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index a7cb8f7..5e7d22a 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <glib.h>
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index c59d5f5..e9a4557 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -243,16 +243,16 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib)
 	return attrib->io;
 }
 
-gboolean g_attrib_set_destroy_function(GAttrib *attrib,
-		GDestroyNotify destroy, gpointer user_data)
+bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
+							gpointer user_data)
 {
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	attrib->destroy = destroy;
 	attrib->destroy_user_data = user_data;
 
-	return TRUE;
+	return true;
 }
 
 static gboolean disconnect_timeout(gpointer data)
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 3fe92c7..9d6a1c2 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -48,8 +48,8 @@ void g_attrib_unref(GAttrib *attrib);
 
 GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 
-gboolean g_attrib_set_destroy_function(GAttrib *attrib,
-		GDestroyNotify destroy, gpointer user_data);
+bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
+							gpointer user_data);
 
 guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 			GAttribResultFunc func, gpointer user_data,
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 6525ebc..44c9ccf 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 #include <glib.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <unistd.h>
 
 #include <bluetooth/bluetooth.h>
diff --git a/attrib/interactive.c b/attrib/interactive.c
index a99ad0a..d6fc89c 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -27,6 +27,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <stdio.h>
 #include <glib.h>
diff --git a/attrib/utils.c b/attrib/utils.c
index f9813d1..1490381 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <stdlib.h>
+#include <stdbool.h>
 #include <glib.h>
 
 #include <bluetooth/bluetooth.h>
-- 
1.8.2


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

* [PATCH BlueZ 07/16] attrib: Change g_attrib_cancel/_all return type
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (5 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

These functions doesn't need to use gboolean as return type.
---
 attrib/gattrib.c | 26 +++++++++++++-------------
 attrib/gattrib.h |  4 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e9a4557..287f114 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -567,14 +567,14 @@ static gint command_cmp_by_id(gconstpointer a, gconstpointer b)
 	return cmd->id - id;
 }
 
-gboolean g_attrib_cancel(GAttrib *attrib, guint id)
+bool g_attrib_cancel(GAttrib *attrib, guint id)
 {
 	GList *l = NULL;
 	struct command *cmd;
 	GQueue *queue;
 
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	queue = attrib->requests;
 	if (queue)
@@ -583,13 +583,13 @@ gboolean g_attrib_cancel(GAttrib *attrib, guint id)
 	if (l == NULL) {
 		queue = attrib->responses;
 		if (!queue)
-			return FALSE;
+			return false;
 		l = g_queue_find_custom(queue, GUINT_TO_POINTER(id),
 					command_cmp_by_id);
 	}
 
 	if (l == NULL)
-		return FALSE;
+		return false;
 
 	cmd = l->data;
 
@@ -600,16 +600,16 @@ gboolean g_attrib_cancel(GAttrib *attrib, guint id)
 		command_destroy(cmd);
 	}
 
-	return TRUE;
+	return true;
 }
 
-static gboolean cancel_all_per_queue(GQueue *queue)
+static bool cancel_all_per_queue(GQueue *queue)
 {
 	struct command *c, *head = NULL;
-	gboolean first = TRUE;
+	bool first = true;
 
 	if (queue == NULL)
-		return FALSE;
+		return false;
 
 	while ((c = g_queue_pop_head(queue))) {
 		if (first && c->sent) {
@@ -619,7 +619,7 @@ static gboolean cancel_all_per_queue(GQueue *queue)
 			continue;
 		}
 
-		first = FALSE;
+		first = false;
 		command_destroy(c);
 	}
 
@@ -628,15 +628,15 @@ static gboolean cancel_all_per_queue(GQueue *queue)
 		g_queue_push_head(queue, head);
 	}
 
-	return TRUE;
+	return true;
 }
 
-gboolean g_attrib_cancel_all(GAttrib *attrib)
+bool g_attrib_cancel_all(GAttrib *attrib)
 {
-	gboolean ret;
+	bool ret;
 
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	ret = cancel_all_per_queue(attrib->requests);
 	ret = cancel_all_per_queue(attrib->responses) && ret;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 9d6a1c2..fe1ebd8 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -55,8 +55,8 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 			GAttribResultFunc func, gpointer user_data,
 			GDestroyNotify notify);
 
-gboolean g_attrib_cancel(GAttrib *attrib, guint id);
-gboolean g_attrib_cancel_all(GAttrib *attrib);
+bool g_attrib_cancel(GAttrib *attrib, guint id);
+bool g_attrib_cancel_all(GAttrib *attrib);
 
 gboolean g_attrib_set_debug(GAttrib *attrib,
 		GAttribDebugFunc func, gpointer user_data);
-- 
1.8.2


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

* [PATCH BlueZ 08/16] attrib: Change g_attrib_unregister/_all return type
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (6 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type for these functions.
---
 attrib/gattrib.c | 14 +++++++-------
 attrib/gattrib.h |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 287f114..1424ef0 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -715,20 +715,20 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib)
 	return sec_level > BT_IO_SEC_LOW;
 }
 
-gboolean g_attrib_unregister(GAttrib *attrib, guint id)
+bool g_attrib_unregister(GAttrib *attrib, guint id)
 {
 	struct event *evt;
 	GSList *l;
 
 	if (id == 0) {
 		warn("%s: invalid id", __FUNCTION__);
-		return FALSE;
+		return false;
 	}
 
 	l = g_slist_find_custom(attrib->events, GUINT_TO_POINTER(id),
 							event_cmp_by_id);
 	if (l == NULL)
-		return FALSE;
+		return false;
 
 	evt = l->data;
 
@@ -739,15 +739,15 @@ gboolean g_attrib_unregister(GAttrib *attrib, guint id)
 
 	g_free(evt);
 
-	return TRUE;
+	return true;
 }
 
-gboolean g_attrib_unregister_all(GAttrib *attrib)
+bool g_attrib_unregister_all(GAttrib *attrib)
 {
 	GSList *l;
 
 	if (attrib->events == NULL)
-		return FALSE;
+		return false;
 
 	for (l = attrib->events; l; l = l->next) {
 		struct event *evt = l->data;
@@ -761,5 +761,5 @@ gboolean g_attrib_unregister_all(GAttrib *attrib)
 	g_slist_free(attrib->events);
 	attrib->events = NULL;
 
-	return TRUE;
+	return true;
 }
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index fe1ebd8..6e5d183 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -70,8 +70,8 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib);
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
 gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
 
-gboolean g_attrib_unregister(GAttrib *attrib, guint id);
-gboolean g_attrib_unregister_all(GAttrib *attrib);
+bool g_attrib_unregister(GAttrib *attrib, guint id);
+bool g_attrib_unregister_all(GAttrib *attrib);
 
 #ifdef __cplusplus
 }
-- 
1.8.2


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

* [PATCH BlueZ 09/16] attrib: Change g_attrib_set_debug return type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (7 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type of g_attrib_set_debug.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 1424ef0..bd24a16 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -644,10 +644,10 @@ bool g_attrib_cancel_all(GAttrib *attrib)
 	return ret;
 }
 
-gboolean g_attrib_set_debug(GAttrib *attrib,
-		GAttribDebugFunc func, gpointer user_data)
+bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
+							gpointer user_data)
 {
-	return TRUE;
+	return true;
 }
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 6e5d183..d3d6d0d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -58,8 +58,8 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 bool g_attrib_cancel(GAttrib *attrib, guint id);
 bool g_attrib_cancel_all(GAttrib *attrib);
 
-gboolean g_attrib_set_debug(GAttrib *attrib,
-		GAttribDebugFunc func, gpointer user_data);
+bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
+							gpointer user_data);
 
 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
-- 
1.8.2


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

* [PATCH BlueZ 10/16] attrib: Change g_attrib_set_mtu return type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (8 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type of g_attrib_set_mtu.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index bd24a16..365a58e 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -660,16 +660,16 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
 	return attrib->buf;
 }
 
-gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
+bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 {
 	if (mtu < ATT_DEFAULT_LE_MTU)
-		return FALSE;
+		return false;
 
 	attrib->buf = g_realloc(attrib->buf, mtu);
 
 	attrib->buflen = mtu;
 
-	return TRUE;
+	return true;
 }
 
 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index d3d6d0d..70c730f 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -68,7 +68,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 gboolean g_attrib_is_encrypted(GAttrib *attrib);
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
-gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
+bool g_attrib_set_mtu(GAttrib *attrib, int mtu);
 
 bool g_attrib_unregister(GAttrib *attrib, guint id);
 bool g_attrib_unregister_all(GAttrib *attrib);
-- 
1.8.2


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

* [PATCH BlueZ 11/16] attrib: Change g_attrib_is_encrypted return type from gboolean
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (9 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

The function g_attrib_is_encrypted don't need to use gboolean as return
type, it can be standard bool type.
This change implies that gatt_channel->encrypted from
src/attrib-server.c can be standard bool type too.
---
 attrib/gattrib.c    | 4 ++--
 attrib/gattrib.h    | 2 +-
 src/attrib-server.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 365a58e..2cb8265 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -703,14 +703,14 @@ static gint event_cmp_by_id(gconstpointer a, gconstpointer b)
 	return evt->id - id;
 }
 
-gboolean g_attrib_is_encrypted(GAttrib *attrib)
+bool g_attrib_is_encrypted(GAttrib *attrib)
 {
 	BtIOSecLevel sec_level;
 
 	if (!bt_io_get(attrib->io, NULL,
 			BT_IO_OPT_SEC_LEVEL, &sec_level,
 			BT_IO_OPT_INVALID))
-		return FALSE;
+		return false;
 
 	return sec_level > BT_IO_SEC_LOW;
 }
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 70c730f..03f4911 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -65,7 +65,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-gboolean g_attrib_is_encrypted(GAttrib *attrib);
+bool g_attrib_is_encrypted(GAttrib *attrib);
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
 bool g_attrib_set_mtu(GAttrib *attrib, int mtu);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 99656e3..7976610 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -75,7 +75,7 @@ struct gatt_channel {
 	guint mtu;
 	gboolean le;
 	guint id;
-	gboolean encrypted;
+	bool encrypted;
 	struct gatt_server *server;
 	guint cleanup_id;
 	struct btd_device *device;
-- 
1.8.2


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

* [PATCH BlueZ 12/16] attrib: Change command->opcode type from guint8
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (10 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of command->opcode, command->expected and event->expected
for a standard type.
---
 attrib/gattrib.c | 12 ++++++------
 attrib/gattrib.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 2cb8265..e7238a6 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -62,10 +62,10 @@ struct _GAttrib {
 
 struct command {
 	guint id;
-	guint8 opcode;
+	uint8_t opcode;
 	guint8 *pdu;
 	guint16 len;
-	guint8 expected;
+	uint8_t expected;
 	bool sent;
 	GAttribResultFunc func;
 	gpointer user_data;
@@ -74,14 +74,14 @@ struct command {
 
 struct event {
 	guint id;
-	guint8 expected;
+	uint8_t expected;
 	guint16 handle;
 	GAttribNotifyFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
 };
 
-static guint8 opcode2expected(guint8 opcode)
+static uint8_t opcode2expected(uint8_t opcode)
 {
 	switch (opcode) {
 	case ATT_OP_MTU_REQ:
@@ -124,7 +124,7 @@ static guint8 opcode2expected(guint8 opcode)
 	return 0;
 }
 
-static bool is_response(guint8 opcode)
+static bool is_response(uint8_t opcode)
 {
 	switch (opcode) {
 	case ATT_OP_ERROR:
@@ -672,7 +672,7 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 03f4911..2cf5b4d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ 13/16] attrib: Change event->handle type from guint16
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (11 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 14/16] attrib: Change command->id type from guint Jefferson Delfes
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of event->handle for a standard type.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e7238a6..ff29fc8 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -75,7 +75,7 @@ struct command {
 struct event {
 	guint id;
 	uint8_t expected;
-	guint16 handle;
+	uint16_t handle;
 	GAttribNotifyFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
@@ -365,7 +365,7 @@ static void wake_up_sender(struct _GAttrib *attrib)
 
 static bool match_event(struct event *evt, const uint8_t *pdu, gsize len)
 {
-	guint16 handle;
+	uint16_t handle;
 
 	if (evt->expected == GATTRIB_ALL_EVENTS)
 		return true;
@@ -672,7 +672,7 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 2cf5b4d..9d98bfe 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ 14/16] attrib: Change command->id type from guint
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (12 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 15/16] attrib: Change event->id " Jefferson Delfes
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of command->id and GAttrib->next_cmd_id for a standard type.
---
 attrib/gattrib.c | 10 +++++-----
 attrib/gattrib.h |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index ff29fc8..438a522 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -54,14 +54,14 @@ struct _GAttrib {
 	GQueue *requests;
 	GQueue *responses;
 	GSList *events;
-	guint next_cmd_id;
+	unsigned int next_cmd_id;
 	GDestroyNotify destroy;
 	gpointer destroy_user_data;
 	bool stale;
 };
 
 struct command {
-	guint id;
+	unsigned int id;
 	uint8_t opcode;
 	guint8 *pdu;
 	guint16 len;
@@ -505,9 +505,9 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	return g_attrib_ref(attrib);
 }
 
-guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
-			GAttribResultFunc func, gpointer user_data,
-			GDestroyNotify notify)
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+				guint16 len, GAttribResultFunc func,
+				gpointer user_data, GDestroyNotify notify)
 {
 	struct command *c;
 	GQueue *queue;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 9d98bfe..06ed450 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -51,9 +51,9 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
 							gpointer user_data);
 
-guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
-			GAttribResultFunc func, gpointer user_data,
-			GDestroyNotify notify);
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+				guint16 len, GAttribResultFunc func,
+				gpointer user_data, GDestroyNotify notify);
 
 bool g_attrib_cancel(GAttrib *attrib, guint id);
 bool g_attrib_cancel_all(GAttrib *attrib);
-- 
1.8.2


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

* [PATCH BlueZ 15/16] attrib: Change event->id type from guint
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (13 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 14/16] attrib: Change command->id type from guint Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-03-28 15:39 ` [PATCH BlueZ 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of event->id for a standard type.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 438a522..3fdcf6d 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -73,7 +73,7 @@ struct command {
 };
 
 struct event {
-	guint id;
+	unsigned int id;
 	uint8_t expected;
 	uint16_t handle;
 	GAttribNotifyFunc func;
@@ -672,11 +672,11 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
+unsigned int g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
-	static guint next_evt_id = 0;
+	static unsigned int next_evt_id = 0;
 	struct event *event;
 
 	event = g_try_new0(struct event, 1);
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 06ed450..4404428 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
+unsigned int g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ 16/16] attrib: Change command->pdu pointer type from guint8
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (14 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 15/16] attrib: Change event->id " Jefferson Delfes
@ 2013-03-28 15:39 ` Jefferson Delfes
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-03-28 15:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change pointer type of command->pdu for a standard type.
---
 attrib/gattrib.c | 4 ++--
 attrib/gattrib.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 3fdcf6d..950d805 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -63,7 +63,7 @@ struct _GAttrib {
 struct command {
 	unsigned int id;
 	uint8_t opcode;
-	guint8 *pdu;
+	uint8_t *pdu;
 	guint16 len;
 	uint8_t expected;
 	bool sent;
@@ -505,7 +505,7 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	return g_attrib_ref(attrib);
 }
 
-unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const uint8_t *pdu,
 				guint16 len, GAttribResultFunc func,
 				gpointer user_data, GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 4404428..5f4477d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -51,7 +51,7 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
 							gpointer user_data);
 
-unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const uint8_t *pdu,
 				guint16 len, GAttribResultFunc func,
 				gpointer user_data, GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage
  2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                   ` (15 preceding siblings ...)
  2013-03-28 15:39 ` [PATCH BlueZ 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
@ 2013-04-10 19:16 ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 01/16] attrib: Simplify boolean tests Jefferson Delfes
                     ` (16 more replies)
  16 siblings, 17 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There are some places that we don't need to use GLib date types. For instance
local variables, fields that dont't go through GLib or return vars.
That patch series do some atomic changes over attrib/gattrib for this purpose

v2: Updated with upstream.

Jefferson Delfes (16):
  attrib: Simplify boolean tests
  attrib: Change GAttrib->stale type from gboolean
  attrib: Change command->sent type from gboolean
  attrib: Change is_response return type from gboolean
  attrib: Change match_event return type from gboolean
  attrib: Change g_attrib_set_destroy_function return type
  attrib: Change g_attrib_cancel/_all return type
  attrib: Change g_attrib_unregister/_all return type
  attrib: Change g_attrib_set_debug return type from gboolean
  attrib: Change g_attrib_set_mtu return type from gboolean
  attrib: Change g_attrib_is_encrypted return type from gboolean
  attrib: Change command->opcode type from guint8
  attrib: Change event->handle type from guint16
  attrib: Change command->id type from guint
  attrib: Change event->id type from guint
  attrib: Change command->pdu pointer type from guint8

 attrib/gatt.c        |   1 +
 attrib/gattrib.c     | 127 ++++++++++++++++++++++++++-------------------------
 attrib/gattrib.h     |  28 ++++++------
 attrib/gatttool.c    |   9 ++--
 attrib/interactive.c |   1 +
 attrib/utils.c       |   1 +
 src/attrib-server.c  |   2 +-
 7 files changed, 87 insertions(+), 82 deletions(-)

-- 
1.8.2


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

* [PATCH BlueZ v2 01/16] attrib: Simplify boolean tests
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
                     ` (15 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Remove unnecessary TRUE/FALSE in boolean tests.
---
 attrib/gattrib.c  | 4 ++--
 attrib/gatttool.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e6d6022..416d17b 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -371,7 +371,7 @@ static gboolean match_event(struct event *evt, const uint8_t *pdu, gsize len)
 	if (evt->expected == GATTRIB_ALL_EVENTS)
 		return TRUE;
 
-	if (is_response(pdu[0]) == FALSE && evt->expected == GATTRIB_ALL_REQS)
+	if (!is_response(pdu[0]) && evt->expected == GATTRIB_ALL_REQS)
 		return TRUE;
 
 	if (evt->expected == pdu[0] && evt->handle == GATTRIB_ALL_HANDLES)
@@ -421,7 +421,7 @@ static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
 			evt->func(buf, len, evt->user_data);
 	}
 
-	if (is_response(buf[0]) == FALSE)
+	if (!is_response(buf[0]))
 		return TRUE;
 
 	if (attrib->timeout_watch > 0) {
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 1dd0c35..8cfac27 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -248,7 +248,7 @@ static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -378,7 +378,7 @@ static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("Characteristic value was written successfully\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -452,7 +452,7 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	att_data_list_free(list);
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -573,7 +573,7 @@ int main(int argc, char *argv[])
 	g_option_context_add_group(context, char_rw_group);
 	g_option_group_add_entries(char_rw_group, char_rw_options);
 
-	if (g_option_context_parse(context, &argc, &argv, &gerr) == FALSE) {
+	if (!g_option_context_parse(context, &argc, &argv, &gerr)) {
 		g_printerr("%s\n", gerr->message);
 		g_error_free(gerr);
 	}
-- 
1.8.2


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

* [PATCH BlueZ v2 02/16] attrib: Change GAttrib->stale type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 01/16] attrib: Simplify boolean tests Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 03/16] attrib: Change command->sent " Jefferson Delfes
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to GAttrib->stale be gboolean.
---
 attrib/gattrib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 416d17b..f6881af 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -27,6 +27,7 @@
 #endif
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <glib.h>
 
@@ -56,7 +57,7 @@ struct _GAttrib {
 	guint next_cmd_id;
 	GDestroyNotify destroy;
 	gpointer destroy_user_data;
-	gboolean stale;
+	bool stale;
 };
 
 struct command {
@@ -279,7 +280,7 @@ static gboolean disconnect_timeout(gpointer data)
 	}
 
 done:
-	attrib->stale = TRUE;
+	attrib->stale = true;
 
 	g_attrib_unref(attrib);
 
-- 
1.8.2


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

* [PATCH BlueZ v2 03/16] attrib: Change command->sent type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 01/16] attrib: Simplify boolean tests Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 04/16] attrib: Change is_response return " Jefferson Delfes
                     ` (13 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to command->sent be gboolean.
---
 attrib/gattrib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index f6881af..41e1ce4 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -66,7 +66,7 @@ struct command {
 	guint8 *pdu;
 	guint16 len;
 	guint8 expected;
-	gboolean sent;
+	bool sent;
 	GAttribResultFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
@@ -337,7 +337,7 @@ static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
 		return TRUE;
 	}
 
-	cmd->sent = TRUE;
+	cmd->sent = true;
 
 	if (attrib->timeout_watch == 0)
 		attrib->timeout_watch = g_timeout_add_seconds(GATT_TIMEOUT,
-- 
1.8.2


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

* [PATCH BlueZ v2 04/16] attrib: Change is_response return type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (2 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 03/16] attrib: Change command->sent " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 05/16] attrib: Change match_event " Jefferson Delfes
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean as return type of is_response.
---
 attrib/gattrib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 41e1ce4..9fda74f 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -124,7 +124,7 @@ static guint8 opcode2expected(guint8 opcode)
 	return 0;
 }
 
-static gboolean is_response(guint8 opcode)
+static bool is_response(guint8 opcode)
 {
 	switch (opcode) {
 	case ATT_OP_ERROR:
@@ -140,10 +140,10 @@ static gboolean is_response(guint8 opcode)
 	case ATT_OP_PREP_WRITE_RESP:
 	case ATT_OP_EXEC_WRITE_RESP:
 	case ATT_OP_HANDLE_CNF:
-		return TRUE;
+		return true;
 	}
 
-	return FALSE;
+	return false;
 }
 
 GAttrib *g_attrib_ref(GAttrib *attrib)
-- 
1.8.2


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

* [PATCH BlueZ v2 05/16] attrib: Change match_event return type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (3 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 04/16] attrib: Change is_response return " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
                     ` (11 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean as return type of match_event.
---
 attrib/gattrib.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 9fda74f..636e09d 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -365,28 +365,28 @@ static void wake_up_sender(struct _GAttrib *attrib)
 				can_write_data, attrib, destroy_sender);
 }
 
-static gboolean match_event(struct event *evt, const uint8_t *pdu, gsize len)
+static bool match_event(struct event *evt, const uint8_t *pdu, gsize len)
 {
 	guint16 handle;
 
 	if (evt->expected == GATTRIB_ALL_EVENTS)
-		return TRUE;
+		return true;
 
 	if (!is_response(pdu[0]) && evt->expected == GATTRIB_ALL_REQS)
-		return TRUE;
+		return true;
 
 	if (evt->expected == pdu[0] && evt->handle == GATTRIB_ALL_HANDLES)
-		return TRUE;
+		return true;
 
 	if (len < 3)
-		return FALSE;
+		return false;
 
 	handle = att_get_u16(&pdu[1]);
 
 	if (evt->expected == pdu[0] && evt->handle == handle)
-		return TRUE;
+		return true;
 
-	return FALSE;
+	return false;
 }
 
 static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
-- 
1.8.2


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

* [PATCH BlueZ v2 06/16] attrib: Change g_attrib_set_destroy_function return type
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (4 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 05/16] attrib: Change match_event " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

The return type from g_attrib_set_destroy_function don't need to be
gboolean, it can be standard bool type.
That change implies change in its signature, which requires stdbool.h to
be included where attrib/gattrib.h is included.
---
 attrib/gatt.c        | 1 +
 attrib/gattrib.c     | 8 ++++----
 attrib/gattrib.h     | 4 ++--
 attrib/gatttool.c    | 1 +
 attrib/interactive.c | 1 +
 attrib/utils.c       | 1 +
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index 749e820..3fe6aeb 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <glib.h>
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 636e09d..9ca9537 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -245,16 +245,16 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib)
 	return attrib->io;
 }
 
-gboolean g_attrib_set_destroy_function(GAttrib *attrib,
-		GDestroyNotify destroy, gpointer user_data)
+bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
+							gpointer user_data)
 {
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	attrib->destroy = destroy;
 	attrib->destroy_user_data = user_data;
 
-	return TRUE;
+	return true;
 }
 
 static gboolean disconnect_timeout(gpointer data)
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 3fe92c7..9d6a1c2 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -48,8 +48,8 @@ void g_attrib_unref(GAttrib *attrib);
 
 GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 
-gboolean g_attrib_set_destroy_function(GAttrib *attrib,
-		GDestroyNotify destroy, gpointer user_data);
+bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
+							gpointer user_data);
 
 guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 			GAttribResultFunc func, gpointer user_data,
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 8cfac27..1f83004 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 #include <glib.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <unistd.h>
 
 #include <bluetooth/bluetooth.h>
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 9f72453..89ae7b9 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -27,6 +27,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <stdio.h>
 #include <glib.h>
diff --git a/attrib/utils.c b/attrib/utils.c
index c8c8651..e4ef650 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <stdlib.h>
+#include <stdbool.h>
 #include <glib.h>
 
 #include <bluetooth/bluetooth.h>
-- 
1.8.2


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

* [PATCH BlueZ v2 07/16] attrib: Change g_attrib_cancel/_all return type
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (5 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
                     ` (9 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

These functions doesn't need to use gboolean as return type.
---
 attrib/gattrib.c | 26 +++++++++++++-------------
 attrib/gattrib.h |  4 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 9ca9537..a21661f 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -564,14 +564,14 @@ static gint command_cmp_by_id(gconstpointer a, gconstpointer b)
 	return cmd->id - id;
 }
 
-gboolean g_attrib_cancel(GAttrib *attrib, guint id)
+bool g_attrib_cancel(GAttrib *attrib, guint id)
 {
 	GList *l = NULL;
 	struct command *cmd;
 	GQueue *queue;
 
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	queue = attrib->requests;
 	if (queue)
@@ -580,13 +580,13 @@ gboolean g_attrib_cancel(GAttrib *attrib, guint id)
 	if (l == NULL) {
 		queue = attrib->responses;
 		if (!queue)
-			return FALSE;
+			return false;
 		l = g_queue_find_custom(queue, GUINT_TO_POINTER(id),
 					command_cmp_by_id);
 	}
 
 	if (l == NULL)
-		return FALSE;
+		return false;
 
 	cmd = l->data;
 
@@ -597,16 +597,16 @@ gboolean g_attrib_cancel(GAttrib *attrib, guint id)
 		command_destroy(cmd);
 	}
 
-	return TRUE;
+	return true;
 }
 
-static gboolean cancel_all_per_queue(GQueue *queue)
+static bool cancel_all_per_queue(GQueue *queue)
 {
 	struct command *c, *head = NULL;
-	gboolean first = TRUE;
+	bool first = true;
 
 	if (queue == NULL)
-		return FALSE;
+		return false;
 
 	while ((c = g_queue_pop_head(queue))) {
 		if (first && c->sent) {
@@ -616,7 +616,7 @@ static gboolean cancel_all_per_queue(GQueue *queue)
 			continue;
 		}
 
-		first = FALSE;
+		first = false;
 		command_destroy(c);
 	}
 
@@ -625,15 +625,15 @@ static gboolean cancel_all_per_queue(GQueue *queue)
 		g_queue_push_head(queue, head);
 	}
 
-	return TRUE;
+	return true;
 }
 
-gboolean g_attrib_cancel_all(GAttrib *attrib)
+bool g_attrib_cancel_all(GAttrib *attrib)
 {
-	gboolean ret;
+	bool ret;
 
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	ret = cancel_all_per_queue(attrib->requests);
 	ret = cancel_all_per_queue(attrib->responses) && ret;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 9d6a1c2..fe1ebd8 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -55,8 +55,8 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 			GAttribResultFunc func, gpointer user_data,
 			GDestroyNotify notify);
 
-gboolean g_attrib_cancel(GAttrib *attrib, guint id);
-gboolean g_attrib_cancel_all(GAttrib *attrib);
+bool g_attrib_cancel(GAttrib *attrib, guint id);
+bool g_attrib_cancel_all(GAttrib *attrib);
 
 gboolean g_attrib_set_debug(GAttrib *attrib,
 		GAttribDebugFunc func, gpointer user_data);
-- 
1.8.2


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

* [PATCH BlueZ v2 08/16] attrib: Change g_attrib_unregister/_all return type
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (6 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
                     ` (8 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type for these functions.
---
 attrib/gattrib.c | 14 +++++++-------
 attrib/gattrib.h |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index a21661f..e7e1e17 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -712,20 +712,20 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib)
 	return sec_level > BT_IO_SEC_LOW;
 }
 
-gboolean g_attrib_unregister(GAttrib *attrib, guint id)
+bool g_attrib_unregister(GAttrib *attrib, guint id)
 {
 	struct event *evt;
 	GSList *l;
 
 	if (id == 0) {
 		warn("%s: invalid id", __FUNCTION__);
-		return FALSE;
+		return false;
 	}
 
 	l = g_slist_find_custom(attrib->events, GUINT_TO_POINTER(id),
 							event_cmp_by_id);
 	if (l == NULL)
-		return FALSE;
+		return false;
 
 	evt = l->data;
 
@@ -736,15 +736,15 @@ gboolean g_attrib_unregister(GAttrib *attrib, guint id)
 
 	g_free(evt);
 
-	return TRUE;
+	return true;
 }
 
-gboolean g_attrib_unregister_all(GAttrib *attrib)
+bool g_attrib_unregister_all(GAttrib *attrib)
 {
 	GSList *l;
 
 	if (attrib->events == NULL)
-		return FALSE;
+		return false;
 
 	for (l = attrib->events; l; l = l->next) {
 		struct event *evt = l->data;
@@ -758,5 +758,5 @@ gboolean g_attrib_unregister_all(GAttrib *attrib)
 	g_slist_free(attrib->events);
 	attrib->events = NULL;
 
-	return TRUE;
+	return true;
 }
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index fe1ebd8..6e5d183 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -70,8 +70,8 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib);
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
 gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
 
-gboolean g_attrib_unregister(GAttrib *attrib, guint id);
-gboolean g_attrib_unregister_all(GAttrib *attrib);
+bool g_attrib_unregister(GAttrib *attrib, guint id);
+bool g_attrib_unregister_all(GAttrib *attrib);
 
 #ifdef __cplusplus
 }
-- 
1.8.2


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

* [PATCH BlueZ v2 09/16] attrib: Change g_attrib_set_debug return type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (7 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
                     ` (7 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type of g_attrib_set_debug.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e7e1e17..51d6bca 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -641,10 +641,10 @@ bool g_attrib_cancel_all(GAttrib *attrib)
 	return ret;
 }
 
-gboolean g_attrib_set_debug(GAttrib *attrib,
-		GAttribDebugFunc func, gpointer user_data)
+bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
+							gpointer user_data)
 {
-	return TRUE;
+	return true;
 }
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 6e5d183..d3d6d0d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -58,8 +58,8 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 bool g_attrib_cancel(GAttrib *attrib, guint id);
 bool g_attrib_cancel_all(GAttrib *attrib);
 
-gboolean g_attrib_set_debug(GAttrib *attrib,
-		GAttribDebugFunc func, gpointer user_data);
+bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
+							gpointer user_data);
 
 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
-- 
1.8.2


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

* [PATCH BlueZ v2 10/16] attrib: Change g_attrib_set_mtu return type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (8 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type of g_attrib_set_mtu.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 51d6bca..1689c72 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -657,16 +657,16 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
 	return attrib->buf;
 }
 
-gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
+bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 {
 	if (mtu < ATT_DEFAULT_LE_MTU)
-		return FALSE;
+		return false;
 
 	attrib->buf = g_realloc(attrib->buf, mtu);
 
 	attrib->buflen = mtu;
 
-	return TRUE;
+	return true;
 }
 
 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index d3d6d0d..70c730f 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -68,7 +68,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 gboolean g_attrib_is_encrypted(GAttrib *attrib);
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
-gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
+bool g_attrib_set_mtu(GAttrib *attrib, int mtu);
 
 bool g_attrib_unregister(GAttrib *attrib, guint id);
 bool g_attrib_unregister_all(GAttrib *attrib);
-- 
1.8.2


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

* [PATCH BlueZ v2 11/16] attrib: Change g_attrib_is_encrypted return type from gboolean
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (9 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

The function g_attrib_is_encrypted don't need to use gboolean as return
type, it can be standard bool type.
This change implies that gatt_channel->encrypted from
src/attrib-server.c can be standard bool type too.
---
 attrib/gattrib.c    | 4 ++--
 attrib/gattrib.h    | 2 +-
 src/attrib-server.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 1689c72..521a714 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -700,14 +700,14 @@ static gint event_cmp_by_id(gconstpointer a, gconstpointer b)
 	return evt->id - id;
 }
 
-gboolean g_attrib_is_encrypted(GAttrib *attrib)
+bool g_attrib_is_encrypted(GAttrib *attrib)
 {
 	BtIOSecLevel sec_level;
 
 	if (!bt_io_get(attrib->io, NULL,
 			BT_IO_OPT_SEC_LEVEL, &sec_level,
 			BT_IO_OPT_INVALID))
-		return FALSE;
+		return false;
 
 	return sec_level > BT_IO_SEC_LOW;
 }
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 70c730f..03f4911 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -65,7 +65,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-gboolean g_attrib_is_encrypted(GAttrib *attrib);
+bool g_attrib_is_encrypted(GAttrib *attrib);
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
 bool g_attrib_set_mtu(GAttrib *attrib, int mtu);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 99656e3..7976610 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -75,7 +75,7 @@ struct gatt_channel {
 	guint mtu;
 	gboolean le;
 	guint id;
-	gboolean encrypted;
+	bool encrypted;
 	struct gatt_server *server;
 	guint cleanup_id;
 	struct btd_device *device;
-- 
1.8.2


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

* [PATCH BlueZ v2 12/16] attrib: Change command->opcode type from guint8
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (10 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
                     ` (4 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of command->opcode, command->expected and event->expected
for a standard type.
---
 attrib/gattrib.c | 12 ++++++------
 attrib/gattrib.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 521a714..57acb09 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -62,10 +62,10 @@ struct _GAttrib {
 
 struct command {
 	guint id;
-	guint8 opcode;
+	uint8_t opcode;
 	guint8 *pdu;
 	guint16 len;
-	guint8 expected;
+	uint8_t expected;
 	bool sent;
 	GAttribResultFunc func;
 	gpointer user_data;
@@ -74,14 +74,14 @@ struct command {
 
 struct event {
 	guint id;
-	guint8 expected;
+	uint8_t expected;
 	guint16 handle;
 	GAttribNotifyFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
 };
 
-static guint8 opcode2expected(guint8 opcode)
+static uint8_t opcode2expected(uint8_t opcode)
 {
 	switch (opcode) {
 	case ATT_OP_MTU_REQ:
@@ -124,7 +124,7 @@ static guint8 opcode2expected(guint8 opcode)
 	return 0;
 }
 
-static bool is_response(guint8 opcode)
+static bool is_response(uint8_t opcode)
 {
 	switch (opcode) {
 	case ATT_OP_ERROR:
@@ -669,7 +669,7 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 03f4911..2cf5b4d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v2 13/16] attrib: Change event->handle type from guint16
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (11 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:16   ` [PATCH BlueZ v2 14/16] attrib: Change command->id type from guint Jefferson Delfes
                     ` (3 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of event->handle for a standard type.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 57acb09..0dd4a87 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -75,7 +75,7 @@ struct command {
 struct event {
 	guint id;
 	uint8_t expected;
-	guint16 handle;
+	uint16_t handle;
 	GAttribNotifyFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
@@ -367,7 +367,7 @@ static void wake_up_sender(struct _GAttrib *attrib)
 
 static bool match_event(struct event *evt, const uint8_t *pdu, gsize len)
 {
-	guint16 handle;
+	uint16_t handle;
 
 	if (evt->expected == GATTRIB_ALL_EVENTS)
 		return true;
@@ -669,7 +669,7 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 2cf5b4d..9d98bfe 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v2 14/16] attrib: Change command->id type from guint
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (12 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
@ 2013-04-10 19:16   ` Jefferson Delfes
  2013-04-10 19:17   ` [PATCH BlueZ v2 15/16] attrib: Change event->id " Jefferson Delfes
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of command->id and GAttrib->next_cmd_id for a standard type.
---
 attrib/gattrib.c | 10 +++++-----
 attrib/gattrib.h |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 0dd4a87..ea85eaa 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -54,14 +54,14 @@ struct _GAttrib {
 	GQueue *requests;
 	GQueue *responses;
 	GSList *events;
-	guint next_cmd_id;
+	unsigned int next_cmd_id;
 	GDestroyNotify destroy;
 	gpointer destroy_user_data;
 	bool stale;
 };
 
 struct command {
-	guint id;
+	unsigned int id;
 	uint8_t opcode;
 	guint8 *pdu;
 	guint16 len;
@@ -502,9 +502,9 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	return g_attrib_ref(attrib);
 }
 
-guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
-			GAttribResultFunc func, gpointer user_data,
-			GDestroyNotify notify)
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+				guint16 len, GAttribResultFunc func,
+				gpointer user_data, GDestroyNotify notify)
 {
 	struct command *c;
 	GQueue *queue;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 9d98bfe..06ed450 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -51,9 +51,9 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
 							gpointer user_data);
 
-guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
-			GAttribResultFunc func, gpointer user_data,
-			GDestroyNotify notify);
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+				guint16 len, GAttribResultFunc func,
+				gpointer user_data, GDestroyNotify notify);
 
 bool g_attrib_cancel(GAttrib *attrib, guint id);
 bool g_attrib_cancel_all(GAttrib *attrib);
-- 
1.8.2


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

* [PATCH BlueZ v2 15/16] attrib: Change event->id type from guint
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (13 preceding siblings ...)
  2013-04-10 19:16   ` [PATCH BlueZ v2 14/16] attrib: Change command->id type from guint Jefferson Delfes
@ 2013-04-10 19:17   ` Jefferson Delfes
  2013-04-10 19:17   ` [PATCH BlueZ v2 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:17 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of event->id for a standard type.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index ea85eaa..e9b5a15 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -73,7 +73,7 @@ struct command {
 };
 
 struct event {
-	guint id;
+	unsigned int id;
 	uint8_t expected;
 	uint16_t handle;
 	GAttribNotifyFunc func;
@@ -669,11 +669,11 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
+unsigned int g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
-	static guint next_evt_id = 0;
+	static unsigned int next_evt_id = 0;
 	struct event *event;
 
 	event = g_try_new0(struct event, 1);
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 06ed450..4404428 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
+unsigned int g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v2 16/16] attrib: Change command->pdu pointer type from guint8
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (14 preceding siblings ...)
  2013-04-10 19:17   ` [PATCH BlueZ v2 15/16] attrib: Change event->id " Jefferson Delfes
@ 2013-04-10 19:17   ` Jefferson Delfes
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  16 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-10 19:17 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change pointer type of command->pdu for a standard type.
---
 attrib/gattrib.c | 4 ++--
 attrib/gattrib.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e9b5a15..b00a8d2 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -63,7 +63,7 @@ struct _GAttrib {
 struct command {
 	unsigned int id;
 	uint8_t opcode;
-	guint8 *pdu;
+	uint8_t *pdu;
 	guint16 len;
 	uint8_t expected;
 	bool sent;
@@ -502,7 +502,7 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	return g_attrib_ref(attrib);
 }
 
-unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const uint8_t *pdu,
 				guint16 len, GAttribResultFunc func,
 				gpointer user_data, GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 4404428..5f4477d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -51,7 +51,7 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
 							gpointer user_data);
 
-unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const uint8_t *pdu,
 				guint16 len, GAttribResultFunc func,
 				gpointer user_data, GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage
  2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                     ` (15 preceding siblings ...)
  2013-04-10 19:17   ` [PATCH BlueZ v2 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
@ 2013-04-17 14:03   ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 01/16] attrib: Simplify boolean tests Jefferson Delfes
                       ` (15 more replies)
  16 siblings, 16 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There are some places that we don't need to use GLib date types. For instance
local variables, fields that dont't go through GLib or return vars.
That patch series do some atomic changes over attrib/gattrib for this purpose.

v3: Updated with upstream.

Jefferson Delfes (16):
  attrib: Simplify boolean tests
  attrib: Change GAttrib->stale type from gboolean
  attrib: Change command->sent type from gboolean
  attrib: Change is_response return type from gboolean
  attrib: Change match_event return type from gboolean
  attrib: Change g_attrib_set_destroy_function return type
  attrib: Change g_attrib_cancel/_all return type
  attrib: Change g_attrib_unregister/_all return type
  attrib: Change g_attrib_set_debug return type from gboolean
  attrib: Change g_attrib_set_mtu return type from gboolean
  attrib: Change g_attrib_is_encrypted return type from gboolean
  attrib: Change command->opcode type from guint8
  attrib: Change event->handle type from guint16
  attrib: Change command->id type from guint
  attrib: Change event->id type from guint
  attrib: Change command->pdu pointer type from guint8

 attrib/gatt.c        |   1 +
 attrib/gattrib.c     | 127 ++++++++++++++++++++++++++-------------------------
 attrib/gattrib.h     |  28 ++++++------
 attrib/gatttool.c    |   9 ++--
 attrib/interactive.c |   1 +
 attrib/utils.c       |   1 +
 src/attrib-server.c  |   2 +-
 7 files changed, 87 insertions(+), 82 deletions(-)

-- 
1.8.2


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

* [PATCH BlueZ v3 01/16] attrib: Simplify boolean tests
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
                       ` (14 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Remove unnecessary TRUE/FALSE in boolean tests.
---
 attrib/gattrib.c  | 4 ++--
 attrib/gatttool.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e6d6022..416d17b 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -371,7 +371,7 @@ static gboolean match_event(struct event *evt, const uint8_t *pdu, gsize len)
 	if (evt->expected == GATTRIB_ALL_EVENTS)
 		return TRUE;
 
-	if (is_response(pdu[0]) == FALSE && evt->expected == GATTRIB_ALL_REQS)
+	if (!is_response(pdu[0]) && evt->expected == GATTRIB_ALL_REQS)
 		return TRUE;
 
 	if (evt->expected == pdu[0] && evt->handle == GATTRIB_ALL_HANDLES)
@@ -421,7 +421,7 @@ static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
 			evt->func(buf, len, evt->user_data);
 	}
 
-	if (is_response(buf[0]) == FALSE)
+	if (!is_response(buf[0]))
 		return TRUE;
 
 	if (attrib->timeout_watch > 0) {
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index e1d8407..dd0f1e2 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -248,7 +248,7 @@ static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -378,7 +378,7 @@ static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("Characteristic value was written successfully\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -452,7 +452,7 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	att_data_list_free(list);
 
 done:
-	if (opt_listen == FALSE)
+	if (!opt_listen)
 		g_main_loop_quit(event_loop);
 }
 
@@ -573,7 +573,7 @@ int main(int argc, char *argv[])
 	g_option_context_add_group(context, char_rw_group);
 	g_option_group_add_entries(char_rw_group, char_rw_options);
 
-	if (g_option_context_parse(context, &argc, &argv, &gerr) == FALSE) {
+	if (!g_option_context_parse(context, &argc, &argv, &gerr)) {
 		g_printerr("%s\n", gerr->message);
 		g_clear_error(&gerr);
 	}
-- 
1.8.2


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

* [PATCH BlueZ v3 02/16] attrib: Change GAttrib->stale type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 01/16] attrib: Simplify boolean tests Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 03/16] attrib: Change command->sent " Jefferson Delfes
                       ` (13 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to GAttrib->stale be gboolean.
---
 attrib/gattrib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 416d17b..f6881af 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -27,6 +27,7 @@
 #endif
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <glib.h>
 
@@ -56,7 +57,7 @@ struct _GAttrib {
 	guint next_cmd_id;
 	GDestroyNotify destroy;
 	gpointer destroy_user_data;
-	gboolean stale;
+	bool stale;
 };
 
 struct command {
@@ -279,7 +280,7 @@ static gboolean disconnect_timeout(gpointer data)
 	}
 
 done:
-	attrib->stale = TRUE;
+	attrib->stale = true;
 
 	g_attrib_unref(attrib);
 
-- 
1.8.2


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

* [PATCH BlueZ v3 03/16] attrib: Change command->sent type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 01/16] attrib: Simplify boolean tests Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 04/16] attrib: Change is_response return " Jefferson Delfes
                       ` (12 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to command->sent be gboolean.
---
 attrib/gattrib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index f6881af..41e1ce4 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -66,7 +66,7 @@ struct command {
 	guint8 *pdu;
 	guint16 len;
 	guint8 expected;
-	gboolean sent;
+	bool sent;
 	GAttribResultFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
@@ -337,7 +337,7 @@ static gboolean can_write_data(GIOChannel *io, GIOCondition cond,
 		return TRUE;
 	}
 
-	cmd->sent = TRUE;
+	cmd->sent = true;
 
 	if (attrib->timeout_watch == 0)
 		attrib->timeout_watch = g_timeout_add_seconds(GATT_TIMEOUT,
-- 
1.8.2


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

* [PATCH BlueZ v3 04/16] attrib: Change is_response return type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (2 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 03/16] attrib: Change command->sent " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 05/16] attrib: Change match_event " Jefferson Delfes
                       ` (11 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean as return type of is_response.
---
 attrib/gattrib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 41e1ce4..9fda74f 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -124,7 +124,7 @@ static guint8 opcode2expected(guint8 opcode)
 	return 0;
 }
 
-static gboolean is_response(guint8 opcode)
+static bool is_response(guint8 opcode)
 {
 	switch (opcode) {
 	case ATT_OP_ERROR:
@@ -140,10 +140,10 @@ static gboolean is_response(guint8 opcode)
 	case ATT_OP_PREP_WRITE_RESP:
 	case ATT_OP_EXEC_WRITE_RESP:
 	case ATT_OP_HANDLE_CNF:
-		return TRUE;
+		return true;
 	}
 
-	return FALSE;
+	return false;
 }
 
 GAttrib *g_attrib_ref(GAttrib *attrib)
-- 
1.8.2


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

* [PATCH BlueZ v3 05/16] attrib: Change match_event return type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (3 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 04/16] attrib: Change is_response return " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
                       ` (10 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean as return type of match_event.
---
 attrib/gattrib.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 9fda74f..636e09d 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -365,28 +365,28 @@ static void wake_up_sender(struct _GAttrib *attrib)
 				can_write_data, attrib, destroy_sender);
 }
 
-static gboolean match_event(struct event *evt, const uint8_t *pdu, gsize len)
+static bool match_event(struct event *evt, const uint8_t *pdu, gsize len)
 {
 	guint16 handle;
 
 	if (evt->expected == GATTRIB_ALL_EVENTS)
-		return TRUE;
+		return true;
 
 	if (!is_response(pdu[0]) && evt->expected == GATTRIB_ALL_REQS)
-		return TRUE;
+		return true;
 
 	if (evt->expected == pdu[0] && evt->handle == GATTRIB_ALL_HANDLES)
-		return TRUE;
+		return true;
 
 	if (len < 3)
-		return FALSE;
+		return false;
 
 	handle = att_get_u16(&pdu[1]);
 
 	if (evt->expected == pdu[0] && evt->handle == handle)
-		return TRUE;
+		return true;
 
-	return FALSE;
+	return false;
 }
 
 static gboolean received_data(GIOChannel *io, GIOCondition cond, gpointer data)
-- 
1.8.2


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

* [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (4 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 05/16] attrib: Change match_event " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-24 14:02       ` Johan Hedberg
  2013-04-17 14:03     ` [PATCH BlueZ v3 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
                       ` (9 subsequent siblings)
  15 siblings, 1 reply; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

The return type from g_attrib_set_destroy_function don't need to be
gboolean, it can be standard bool type.
That change implies change in its signature, which requires stdbool.h to
be included where attrib/gattrib.h is included.
---
 attrib/gatt.c        | 1 +
 attrib/gattrib.c     | 8 ++++----
 attrib/gattrib.h     | 4 ++--
 attrib/gatttool.c    | 1 +
 attrib/interactive.c | 1 +
 attrib/utils.c       | 1 +
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index 749e820..3fe6aeb 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <glib.h>
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 636e09d..9ca9537 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -245,16 +245,16 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib)
 	return attrib->io;
 }
 
-gboolean g_attrib_set_destroy_function(GAttrib *attrib,
-		GDestroyNotify destroy, gpointer user_data)
+bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
+							gpointer user_data)
 {
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	attrib->destroy = destroy;
 	attrib->destroy_user_data = user_data;
 
-	return TRUE;
+	return true;
 }
 
 static gboolean disconnect_timeout(gpointer data)
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 3fe92c7..9d6a1c2 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -48,8 +48,8 @@ void g_attrib_unref(GAttrib *attrib);
 
 GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 
-gboolean g_attrib_set_destroy_function(GAttrib *attrib,
-		GDestroyNotify destroy, gpointer user_data);
+bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
+							gpointer user_data);
 
 guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 			GAttribResultFunc func, gpointer user_data,
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index dd0f1e2..f57cd42 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 #include <glib.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <unistd.h>
 
 #include <bluetooth/bluetooth.h>
diff --git a/attrib/interactive.c b/attrib/interactive.c
index a819acf..fdbdea6 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
diff --git a/attrib/utils.c b/attrib/utils.c
index e263bcb..9966a23 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <stdlib.h>
+#include <stdbool.h>
 #include <glib.h>
 
 #include <bluetooth/bluetooth.h>
-- 
1.8.2


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

* [PATCH BlueZ v3 07/16] attrib: Change g_attrib_cancel/_all return type
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (5 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
                       ` (8 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

These functions doesn't need to use gboolean as return type.
---
 attrib/gattrib.c | 26 +++++++++++++-------------
 attrib/gattrib.h |  4 ++--
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 9ca9537..a21661f 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -564,14 +564,14 @@ static gint command_cmp_by_id(gconstpointer a, gconstpointer b)
 	return cmd->id - id;
 }
 
-gboolean g_attrib_cancel(GAttrib *attrib, guint id)
+bool g_attrib_cancel(GAttrib *attrib, guint id)
 {
 	GList *l = NULL;
 	struct command *cmd;
 	GQueue *queue;
 
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	queue = attrib->requests;
 	if (queue)
@@ -580,13 +580,13 @@ gboolean g_attrib_cancel(GAttrib *attrib, guint id)
 	if (l == NULL) {
 		queue = attrib->responses;
 		if (!queue)
-			return FALSE;
+			return false;
 		l = g_queue_find_custom(queue, GUINT_TO_POINTER(id),
 					command_cmp_by_id);
 	}
 
 	if (l == NULL)
-		return FALSE;
+		return false;
 
 	cmd = l->data;
 
@@ -597,16 +597,16 @@ gboolean g_attrib_cancel(GAttrib *attrib, guint id)
 		command_destroy(cmd);
 	}
 
-	return TRUE;
+	return true;
 }
 
-static gboolean cancel_all_per_queue(GQueue *queue)
+static bool cancel_all_per_queue(GQueue *queue)
 {
 	struct command *c, *head = NULL;
-	gboolean first = TRUE;
+	bool first = true;
 
 	if (queue == NULL)
-		return FALSE;
+		return false;
 
 	while ((c = g_queue_pop_head(queue))) {
 		if (first && c->sent) {
@@ -616,7 +616,7 @@ static gboolean cancel_all_per_queue(GQueue *queue)
 			continue;
 		}
 
-		first = FALSE;
+		first = false;
 		command_destroy(c);
 	}
 
@@ -625,15 +625,15 @@ static gboolean cancel_all_per_queue(GQueue *queue)
 		g_queue_push_head(queue, head);
 	}
 
-	return TRUE;
+	return true;
 }
 
-gboolean g_attrib_cancel_all(GAttrib *attrib)
+bool g_attrib_cancel_all(GAttrib *attrib)
 {
-	gboolean ret;
+	bool ret;
 
 	if (attrib == NULL)
-		return FALSE;
+		return false;
 
 	ret = cancel_all_per_queue(attrib->requests);
 	ret = cancel_all_per_queue(attrib->responses) && ret;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 9d6a1c2..fe1ebd8 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -55,8 +55,8 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 			GAttribResultFunc func, gpointer user_data,
 			GDestroyNotify notify);
 
-gboolean g_attrib_cancel(GAttrib *attrib, guint id);
-gboolean g_attrib_cancel_all(GAttrib *attrib);
+bool g_attrib_cancel(GAttrib *attrib, guint id);
+bool g_attrib_cancel_all(GAttrib *attrib);
 
 gboolean g_attrib_set_debug(GAttrib *attrib,
 		GAttribDebugFunc func, gpointer user_data);
-- 
1.8.2


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

* [PATCH BlueZ v3 08/16] attrib: Change g_attrib_unregister/_all return type
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (6 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
                       ` (7 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type for these functions.
---
 attrib/gattrib.c | 14 +++++++-------
 attrib/gattrib.h |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index a21661f..e7e1e17 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -712,20 +712,20 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib)
 	return sec_level > BT_IO_SEC_LOW;
 }
 
-gboolean g_attrib_unregister(GAttrib *attrib, guint id)
+bool g_attrib_unregister(GAttrib *attrib, guint id)
 {
 	struct event *evt;
 	GSList *l;
 
 	if (id == 0) {
 		warn("%s: invalid id", __FUNCTION__);
-		return FALSE;
+		return false;
 	}
 
 	l = g_slist_find_custom(attrib->events, GUINT_TO_POINTER(id),
 							event_cmp_by_id);
 	if (l == NULL)
-		return FALSE;
+		return false;
 
 	evt = l->data;
 
@@ -736,15 +736,15 @@ gboolean g_attrib_unregister(GAttrib *attrib, guint id)
 
 	g_free(evt);
 
-	return TRUE;
+	return true;
 }
 
-gboolean g_attrib_unregister_all(GAttrib *attrib)
+bool g_attrib_unregister_all(GAttrib *attrib)
 {
 	GSList *l;
 
 	if (attrib->events == NULL)
-		return FALSE;
+		return false;
 
 	for (l = attrib->events; l; l = l->next) {
 		struct event *evt = l->data;
@@ -758,5 +758,5 @@ gboolean g_attrib_unregister_all(GAttrib *attrib)
 	g_slist_free(attrib->events);
 	attrib->events = NULL;
 
-	return TRUE;
+	return true;
 }
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index fe1ebd8..6e5d183 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -70,8 +70,8 @@ gboolean g_attrib_is_encrypted(GAttrib *attrib);
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
 gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
 
-gboolean g_attrib_unregister(GAttrib *attrib, guint id);
-gboolean g_attrib_unregister_all(GAttrib *attrib);
+bool g_attrib_unregister(GAttrib *attrib, guint id);
+bool g_attrib_unregister_all(GAttrib *attrib);
 
 #ifdef __cplusplus
 }
-- 
1.8.2


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

* [PATCH BlueZ v3 09/16] attrib: Change g_attrib_set_debug return type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (7 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
                       ` (6 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type of g_attrib_set_debug.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e7e1e17..51d6bca 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -641,10 +641,10 @@ bool g_attrib_cancel_all(GAttrib *attrib)
 	return ret;
 }
 
-gboolean g_attrib_set_debug(GAttrib *attrib,
-		GAttribDebugFunc func, gpointer user_data)
+bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
+							gpointer user_data)
 {
-	return TRUE;
+	return true;
 }
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 6e5d183..d3d6d0d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -58,8 +58,8 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
 bool g_attrib_cancel(GAttrib *attrib, guint id);
 bool g_attrib_cancel_all(GAttrib *attrib);
 
-gboolean g_attrib_set_debug(GAttrib *attrib,
-		GAttribDebugFunc func, gpointer user_data);
+bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
+							gpointer user_data);
 
 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
-- 
1.8.2


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

* [PATCH BlueZ v3 10/16] attrib: Change g_attrib_set_mtu return type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (8 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
                       ` (5 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

There is no reason to use gboolean in return type of g_attrib_set_mtu.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 51d6bca..1689c72 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -657,16 +657,16 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
 	return attrib->buf;
 }
 
-gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
+bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 {
 	if (mtu < ATT_DEFAULT_LE_MTU)
-		return FALSE;
+		return false;
 
 	attrib->buf = g_realloc(attrib->buf, mtu);
 
 	attrib->buflen = mtu;
 
-	return TRUE;
+	return true;
 }
 
 guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index d3d6d0d..70c730f 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -68,7 +68,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 gboolean g_attrib_is_encrypted(GAttrib *attrib);
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
-gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu);
+bool g_attrib_set_mtu(GAttrib *attrib, int mtu);
 
 bool g_attrib_unregister(GAttrib *attrib, guint id);
 bool g_attrib_unregister_all(GAttrib *attrib);
-- 
1.8.2


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

* [PATCH BlueZ v3 11/16] attrib: Change g_attrib_is_encrypted return type from gboolean
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (9 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
                       ` (4 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

The function g_attrib_is_encrypted don't need to use gboolean as return
type, it can be standard bool type.
This change implies that gatt_channel->encrypted from
src/attrib-server.c can be standard bool type too.
---
 attrib/gattrib.c    | 4 ++--
 attrib/gattrib.h    | 2 +-
 src/attrib-server.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 1689c72..521a714 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -700,14 +700,14 @@ static gint event_cmp_by_id(gconstpointer a, gconstpointer b)
 	return evt->id - id;
 }
 
-gboolean g_attrib_is_encrypted(GAttrib *attrib)
+bool g_attrib_is_encrypted(GAttrib *attrib)
 {
 	BtIOSecLevel sec_level;
 
 	if (!bt_io_get(attrib->io, NULL,
 			BT_IO_OPT_SEC_LEVEL, &sec_level,
 			BT_IO_OPT_INVALID))
-		return FALSE;
+		return false;
 
 	return sec_level > BT_IO_SEC_LOW;
 }
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 70c730f..03f4911 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -65,7 +65,7 @@ guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-gboolean g_attrib_is_encrypted(GAttrib *attrib);
+bool g_attrib_is_encrypted(GAttrib *attrib);
 
 uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len);
 bool g_attrib_set_mtu(GAttrib *attrib, int mtu);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 99656e3..7976610 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -75,7 +75,7 @@ struct gatt_channel {
 	guint mtu;
 	gboolean le;
 	guint id;
-	gboolean encrypted;
+	bool encrypted;
 	struct gatt_server *server;
 	guint cleanup_id;
 	struct btd_device *device;
-- 
1.8.2


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

* [PATCH BlueZ v3 12/16] attrib: Change command->opcode type from guint8
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (10 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
                       ` (3 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of command->opcode, command->expected and event->expected
for a standard type.
---
 attrib/gattrib.c | 12 ++++++------
 attrib/gattrib.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 521a714..57acb09 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -62,10 +62,10 @@ struct _GAttrib {
 
 struct command {
 	guint id;
-	guint8 opcode;
+	uint8_t opcode;
 	guint8 *pdu;
 	guint16 len;
-	guint8 expected;
+	uint8_t expected;
 	bool sent;
 	GAttribResultFunc func;
 	gpointer user_data;
@@ -74,14 +74,14 @@ struct command {
 
 struct event {
 	guint id;
-	guint8 expected;
+	uint8_t expected;
 	guint16 handle;
 	GAttribNotifyFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
 };
 
-static guint8 opcode2expected(guint8 opcode)
+static uint8_t opcode2expected(uint8_t opcode)
 {
 	switch (opcode) {
 	case ATT_OP_MTU_REQ:
@@ -124,7 +124,7 @@ static guint8 opcode2expected(guint8 opcode)
 	return 0;
 }
 
-static bool is_response(guint8 opcode)
+static bool is_response(uint8_t opcode)
 {
 	switch (opcode) {
 	case ATT_OP_ERROR:
@@ -669,7 +669,7 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 03f4911..2cf5b4d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, guint8 opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v3 13/16] attrib: Change event->handle type from guint16
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (11 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 14/16] attrib: Change command->id type from guint Jefferson Delfes
                       ` (2 subsequent siblings)
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of event->handle for a standard type.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 57acb09..0dd4a87 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -75,7 +75,7 @@ struct command {
 struct event {
 	guint id;
 	uint8_t expected;
-	guint16 handle;
+	uint16_t handle;
 	GAttribNotifyFunc func;
 	gpointer user_data;
 	GDestroyNotify notify;
@@ -367,7 +367,7 @@ static void wake_up_sender(struct _GAttrib *attrib)
 
 static bool match_event(struct event *evt, const uint8_t *pdu, gsize len)
 {
-	guint16 handle;
+	uint16_t handle;
 
 	if (evt->expected == GATTRIB_ALL_EVENTS)
 		return true;
@@ -669,7 +669,7 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 2cf5b4d..9d98bfe 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, guint16 handle,
+guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v3 14/16] attrib: Change command->id type from guint
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (12 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 15/16] attrib: Change event->id " Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of command->id and GAttrib->next_cmd_id for a standard type.
---
 attrib/gattrib.c | 10 +++++-----
 attrib/gattrib.h |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 0dd4a87..ea85eaa 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -54,14 +54,14 @@ struct _GAttrib {
 	GQueue *requests;
 	GQueue *responses;
 	GSList *events;
-	guint next_cmd_id;
+	unsigned int next_cmd_id;
 	GDestroyNotify destroy;
 	gpointer destroy_user_data;
 	bool stale;
 };
 
 struct command {
-	guint id;
+	unsigned int id;
 	uint8_t opcode;
 	guint8 *pdu;
 	guint16 len;
@@ -502,9 +502,9 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	return g_attrib_ref(attrib);
 }
 
-guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
-			GAttribResultFunc func, gpointer user_data,
-			GDestroyNotify notify)
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+				guint16 len, GAttribResultFunc func,
+				gpointer user_data, GDestroyNotify notify)
 {
 	struct command *c;
 	GQueue *queue;
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 9d98bfe..06ed450 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -51,9 +51,9 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
 							gpointer user_data);
 
-guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
-			GAttribResultFunc func, gpointer user_data,
-			GDestroyNotify notify);
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+				guint16 len, GAttribResultFunc func,
+				gpointer user_data, GDestroyNotify notify);
 
 bool g_attrib_cancel(GAttrib *attrib, guint id);
 bool g_attrib_cancel_all(GAttrib *attrib);
-- 
1.8.2


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

* [PATCH BlueZ v3 15/16] attrib: Change event->id type from guint
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (13 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 14/16] attrib: Change command->id type from guint Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  2013-04-17 14:03     ` [PATCH BlueZ v3 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change type of event->id for a standard type.
---
 attrib/gattrib.c | 6 +++---
 attrib/gattrib.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index ea85eaa..e9b5a15 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -73,7 +73,7 @@ struct command {
 };
 
 struct event {
-	guint id;
+	unsigned int id;
 	uint8_t expected;
 	uint16_t handle;
 	GAttribNotifyFunc func;
@@ -669,11 +669,11 @@ bool g_attrib_set_mtu(GAttrib *attrib, int mtu)
 	return true;
 }
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
+unsigned int g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify)
 {
-	static guint next_evt_id = 0;
+	static unsigned int next_evt_id = 0;
 	struct event *event;
 
 	event = g_try_new0(struct event, 1);
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 06ed450..4404428 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -61,7 +61,7 @@ bool g_attrib_cancel_all(GAttrib *attrib);
 bool g_attrib_set_debug(GAttrib *attrib, GAttribDebugFunc func,
 							gpointer user_data);
 
-guint g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
+unsigned int g_attrib_register(GAttrib *attrib, uint8_t opcode, uint16_t handle,
 				GAttribNotifyFunc func, gpointer user_data,
 				GDestroyNotify notify);
 
-- 
1.8.2


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

* [PATCH BlueZ v3 16/16] attrib: Change command->pdu pointer type from guint8
  2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
                       ` (14 preceding siblings ...)
  2013-04-17 14:03     ` [PATCH BlueZ v3 15/16] attrib: Change event->id " Jefferson Delfes
@ 2013-04-17 14:03     ` Jefferson Delfes
  15 siblings, 0 replies; 53+ messages in thread
From: Jefferson Delfes @ 2013-04-17 14:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jefferson Delfes

Change pointer type of command->pdu for a standard type.
---
 attrib/gattrib.c | 4 ++--
 attrib/gattrib.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index e9b5a15..b00a8d2 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -63,7 +63,7 @@ struct _GAttrib {
 struct command {
 	unsigned int id;
 	uint8_t opcode;
-	guint8 *pdu;
+	uint8_t *pdu;
 	guint16 len;
 	uint8_t expected;
 	bool sent;
@@ -502,7 +502,7 @@ GAttrib *g_attrib_new(GIOChannel *io)
 	return g_attrib_ref(attrib);
 }
 
-unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const uint8_t *pdu,
 				guint16 len, GAttribResultFunc func,
 				gpointer user_data, GDestroyNotify notify)
 {
diff --git a/attrib/gattrib.h b/attrib/gattrib.h
index 4404428..5f4477d 100644
--- a/attrib/gattrib.h
+++ b/attrib/gattrib.h
@@ -51,7 +51,7 @@ GIOChannel *g_attrib_get_channel(GAttrib *attrib);
 bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
 							gpointer user_data);
 
-unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const guint8 *pdu,
+unsigned int g_attrib_send(GAttrib *attrib, unsigned int id, const uint8_t *pdu,
 				guint16 len, GAttribResultFunc func,
 				gpointer user_data, GDestroyNotify notify);
 
-- 
1.8.2


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

* Re: [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type
  2013-04-17 14:03     ` [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
@ 2013-04-24 14:02       ` Johan Hedberg
  2013-05-02 16:05         ` Marcel Holtmann
  0 siblings, 1 reply; 53+ messages in thread
From: Johan Hedberg @ 2013-04-24 14:02 UTC (permalink / raw)
  To: Jefferson Delfes; +Cc: linux-bluetooth, marcel

Hi Jefferson,

On Wed, Apr 17, 2013, Jefferson Delfes wrote:
> -gboolean g_attrib_set_destroy_function(GAttrib *attrib,
> -		GDestroyNotify destroy, gpointer user_data)
> +bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
> +							gpointer user_data)

I've applied patches 1-5 but stopped there since I'm still not sure that
we want to change this for an API which tries to follow GLib conventions
(after all that's why the GAttrib API has G and g_ prefixes). Marcel, do
you have any opinion about this one way or another?

Johan

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

* Re: [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type
  2013-04-24 14:02       ` Johan Hedberg
@ 2013-05-02 16:05         ` Marcel Holtmann
  0 siblings, 0 replies; 53+ messages in thread
From: Marcel Holtmann @ 2013-05-02 16:05 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: Jefferson Delfes, linux-bluetooth

Hi Johan,

>> -gboolean g_attrib_set_destroy_function(GAttrib *attrib,
>> -		GDestroyNotify destroy, gpointer user_data)
>> +bool g_attrib_set_destroy_function(GAttrib *attrib, GDestroyNotify destroy,
>> +							gpointer user_data)
> 
> I've applied patches 1-5 but stopped there since I'm still not sure that
> we want to change this for an API which tries to follow GLib conventions
> (after all that's why the GAttrib API has G and g_ prefixes). Marcel, do
> you have any opinion about this one way or another?

the long term plan is to use standard types like bool, char, uint8_t and also void * here. However we might want to also see how to get rid of g_ prefix as well. Especially g_attrib seems to be a good candidate to get rid of.

I also like to see ATT and GATT being implemented as src/shared/ under LGPL so we can be easily share it in the future. I already have some (unpublished) code for src/shared/att.[ch] and src/shared/gatt.[ch] already, but I think what we first need to do is to figure out how we handle clients and servers from the kernel side. Especially with the background of the kernel auto-connecting LE channels in the future.

Regards

Marcel


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

end of thread, other threads:[~2013-05-02 16:05 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 15:39 [PATCH BlueZ 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 01/16] attrib: Simplify boolean tests Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 03/16] attrib: Change command->sent " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 04/16] attrib: Change is_response return " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 05/16] attrib: Change match_event " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 14/16] attrib: Change command->id type from guint Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 15/16] attrib: Change event->id " Jefferson Delfes
2013-03-28 15:39 ` [PATCH BlueZ 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
2013-04-10 19:16 ` [PATCH BlueZ v2 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 01/16] attrib: Simplify boolean tests Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 03/16] attrib: Change command->sent " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 04/16] attrib: Change is_response return " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 05/16] attrib: Change match_event " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
2013-04-10 19:16   ` [PATCH BlueZ v2 14/16] attrib: Change command->id type from guint Jefferson Delfes
2013-04-10 19:17   ` [PATCH BlueZ v2 15/16] attrib: Change event->id " Jefferson Delfes
2013-04-10 19:17   ` [PATCH BlueZ v2 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes
2013-04-17 14:03   ` [PATCH BlueZ v3 00/16] attrib: Replace GLib basic data types usage Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 01/16] attrib: Simplify boolean tests Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 02/16] attrib: Change GAttrib->stale type from gboolean Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 03/16] attrib: Change command->sent " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 04/16] attrib: Change is_response return " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 05/16] attrib: Change match_event " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 06/16] attrib: Change g_attrib_set_destroy_function return type Jefferson Delfes
2013-04-24 14:02       ` Johan Hedberg
2013-05-02 16:05         ` Marcel Holtmann
2013-04-17 14:03     ` [PATCH BlueZ v3 07/16] attrib: Change g_attrib_cancel/_all " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 08/16] attrib: Change g_attrib_unregister/_all " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 09/16] attrib: Change g_attrib_set_debug return type from gboolean Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 10/16] attrib: Change g_attrib_set_mtu " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 11/16] attrib: Change g_attrib_is_encrypted " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 12/16] attrib: Change command->opcode type from guint8 Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 13/16] attrib: Change event->handle type from guint16 Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 14/16] attrib: Change command->id type from guint Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 15/16] attrib: Change event->id " Jefferson Delfes
2013-04-17 14:03     ` [PATCH BlueZ v3 16/16] attrib: Change command->pdu pointer type from guint8 Jefferson Delfes

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