* [PATCH BlueZ] input/hog-lib: add error handling when calling into gatt
@ 2021-04-07 22:35 Sonny Sasaka
2021-04-07 23:04 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Sonny Sasaka @ 2021-04-07 22:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitry Torokhov
From: Dmitry Torokhov <dtor@chromium.org>
When calling gatt_write_char(), gatt_read_char(), etc, id == 0 indicates
error. Let's recognize this fact and log it instead of queueing request
that will never be completed.
---
profiles/input/hog-lib.c | 77 +++++++++++++++++++++++++---------------
1 file changed, 48 insertions(+), 29 deletions(-)
diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 6ac14e401..668f8047a 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -166,13 +166,16 @@ static void write_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
return;
id = gatt_write_char(attrib, handle, value, vlen, func, req);
-
- if (set_and_store_gatt_req(hog, req, id))
+ if (!id) {
+ error("hog: Could not write char");
return;
+ }
- error("hog: Could not read char");
- g_attrib_cancel(attrib, id);
- free(req);
+ if (!set_and_store_gatt_req(hog, req, id)) {
+ error("hog: Failed to queue write char req");
+ g_attrib_cancel(attrib, id);
+ free(req);
+ }
}
static void read_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
@@ -190,13 +193,16 @@ static void read_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
return;
id = gatt_read_char(attrib, handle, func, req);
-
- if (set_and_store_gatt_req(hog, req, id))
+ if (!id) {
+ error("hog: Could not read char");
return;
+ }
- error("hog: Could not read char");
- g_attrib_cancel(attrib, id);
- free(req);
+ if (!set_and_store_gatt_req(hog, req, id)) {
+ error("hog: Failed to queue read char req");
+ g_attrib_cancel(attrib, id);
+ free(req);
+ }
}
static void discover_desc(struct bt_hog *hog, GAttrib *attrib,
@@ -211,12 +217,16 @@ static void discover_desc(struct bt_hog *hog, GAttrib *attrib,
return;
id = gatt_discover_desc(attrib, start, end, NULL, func, req);
- if (set_and_store_gatt_req(hog, req, id))
+ if (!id) {
+ error("hog: Could not discover descriptors");
return;
+ }
- error("hog: Could not discover descriptors");
- g_attrib_cancel(attrib, id);
- free(req);
+ if (!set_and_store_gatt_req(hog, req, id)) {
+ error("hog: Failed to queue discover descriptors req");
+ g_attrib_cancel(attrib, id);
+ free(req);
+ }
}
static void discover_char(struct bt_hog *hog, GAttrib *attrib,
@@ -232,13 +242,16 @@ static void discover_char(struct bt_hog *hog, GAttrib *attrib,
return;
id = gatt_discover_char(attrib, start, end, uuid, func, req);
-
- if (set_and_store_gatt_req(hog, req, id))
+ if (!id) {
+ error("hog: Could not discover characteristic");
return;
+ }
- error("hog: Could not discover characteristic");
- g_attrib_cancel(attrib, id);
- free(req);
+ if (!set_and_store_gatt_req(hog, req, id)) {
+ error("hog: Failed to queue discover characteristic req");
+ g_attrib_cancel(attrib, id);
+ free(req);
+ }
}
static void discover_primary(struct bt_hog *hog, GAttrib *attrib,
@@ -253,13 +266,16 @@ static void discover_primary(struct bt_hog *hog, GAttrib *attrib,
return;
id = gatt_discover_primary(attrib, uuid, func, req);
-
- if (set_and_store_gatt_req(hog, req, id))
+ if (!id) {
+ error("hog: Could not send discover primary");
return;
+ }
- error("hog: Could not send discover primary");
- g_attrib_cancel(attrib, id);
- free(req);
+ if (!set_and_store_gatt_req(hog, req, id)) {
+ error("hog: Failed to queue discover primary req");
+ g_attrib_cancel(attrib, id);
+ free(req);
+ }
}
static void find_included(struct bt_hog *hog, GAttrib *attrib,
@@ -274,13 +290,16 @@ static void find_included(struct bt_hog *hog, GAttrib *attrib,
return;
id = gatt_find_included(attrib, start, end, func, req);
-
- if (set_and_store_gatt_req(hog, req, id))
+ if (!id) {
+ error("hog: Could not find included");
return;
+ }
- error("Could not find included");
- g_attrib_cancel(attrib, id);
- free(req);
+ if (!set_and_store_gatt_req(hog, req, id)) {
+ error("hog: Failed to queue find included req");
+ g_attrib_cancel(attrib, id);
+ free(req);
+ }
}
static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
--
2.31.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [BlueZ] input/hog-lib: add error handling when calling into gatt
2021-04-07 22:35 [PATCH BlueZ] input/hog-lib: add error handling when calling into gatt Sonny Sasaka
@ 2021-04-07 23:04 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2021-04-07 23:04 UTC (permalink / raw)
To: linux-bluetooth, sonnysasaka
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=462833
---Test result---
##############################
Test: CheckPatch - PASS
##############################
Test: CheckGitLint - PASS
##############################
Test: CheckBuild: Setup ELL - PASS
##############################
Test: CheckBuild: Setup - PASS
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
##############################
Test: CheckBuild w/external ell - PASS
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-07 23:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 22:35 [PATCH BlueZ] input/hog-lib: add error handling when calling into gatt Sonny Sasaka
2021-04-07 23:04 ` [BlueZ] " bluez.test.bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.