Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 01/10] android/gatt: Replace request state with boolean
@ 2015-02-11 14:33 Jakub Tyszkowski
  2015-02-11 14:34 ` [PATCH 02/10] android/gatt: Destroy app connections before destroying apps Jakub Tyszkowski
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Jakub Tyszkowski @ 2015-02-11 14:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

As there are two states we can instead use boolean value.
---
 android/gatt.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 8e58e41..b0ce1a8 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -690,11 +690,6 @@ static void destroy_gatt_app(void *data)
 	free(app);
 }
 
-enum pend_req_state {
-	REQUEST_PENDING,
-	REQUEST_DONE,
-};
-
 struct pending_request {
 	struct gatt_db_attribute *attrib;
 	int length;
@@ -704,7 +699,7 @@ struct pending_request {
 	uint8_t *filter_value;
 	uint16_t filter_vlen;
 
-	enum pend_req_state state;
+	bool completed;
 	uint8_t error;
 };
 
@@ -4475,7 +4470,7 @@ static bool match_pending_dev_request(const void *data, const void *user_data)
 {
 	const struct pending_request *pending_request = data;
 
-	return pending_request->state == REQUEST_PENDING;
+	return !pending_request->completed;
 }
 
 static void send_dev_complete_response(struct gatt_device *device,
@@ -4830,7 +4825,7 @@ static void attribute_read_cb(struct gatt_db_attribute *attrib, int err,
 	resp_data->length = length;
 	resp_data->error = error;
 
-	resp_data->state = REQUEST_DONE;
+	resp_data->completed = true;
 
 	if (!length)
 		return;
@@ -4856,7 +4851,7 @@ static void read_requested_attributes(void *data, void *user_data)
 	attrib = resp_data->attrib;
 	if (!attrib) {
 		resp_data->error = ATT_ECODE_ATTR_NOT_FOUND;
-		resp_data->state = REQUEST_DONE;
+		resp_data->completed = true;
 		return;
 	}
 
@@ -4874,7 +4869,7 @@ static void read_requested_attributes(void *data, void *user_data)
 							permissions);
 	if (error != 0) {
 		resp_data->error = error;
-		resp_data->state = REQUEST_DONE;
+		resp_data->completed = true;
 		return;
 	}
 
@@ -5650,7 +5645,7 @@ static void handle_server_send_response(const void *buf, uint16_t len)
 
 		/* Cast status to uint8_t, due to (byte) cast in java layer. */
 		req->error = err_to_att((uint8_t) cmd->status);
-		req->state = REQUEST_DONE;
+		req->completed = true;
 
 		/*
 		 * FIXME: Handle situation when not all server applications
@@ -6493,7 +6488,7 @@ static void attribute_write_cb(struct gatt_db_attribute *attrib, int err,
 	data->attrib = attrib;
 	data->error = error;
 
-	data->state = REQUEST_DONE;
+	data->completed = true;
 }
 
 static uint8_t write_req_request(const uint8_t *cmd, uint16_t cmd_len,
-- 
1.9.1


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

end of thread, other threads:[~2015-02-13 13:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-11 14:33 [PATCH 01/10] android/gatt: Replace request state with boolean Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 02/10] android/gatt: Destroy app connections before destroying apps Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 03/10] android/gatt: Simplify app disconnection function call flow Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 04/10] android/gatt: Make struct destructors NULL proof Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 05/10] android/gatt: Use g_attrib_send consistently Jakub Tyszkowski
2015-02-13 11:31   ` Szymon Janc
2015-02-13 12:49     ` Tyszkowski Jakub
2015-02-11 14:34 ` [PATCH 06/10] android/gatt: Improve send_dev_complete_response Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 07/10] android/gatt: Improve send_dev_complete_response even further Jakub Tyszkowski
2015-02-13 11:35   ` Szymon Janc
2015-02-13 13:38     ` Tyszkowski Jakub
2015-02-11 14:34 ` [PATCH 08/10] android/gatt: Remove not needed checks and jumps Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 09/10] android/gatt: Remove redundant matching function Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 10/10] android/gatt: Avoid copying pointers in matching functions Jakub Tyszkowski
2015-02-13 11:48   ` Szymon Janc
2015-02-13 13:25     ` Tyszkowski Jakub
2015-02-13 11:49 ` [PATCH 01/10] android/gatt: Replace request state with boolean Szymon Janc

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