From: Joao Paulo Rechi Vita <jprvita@openbossa.org>
To: Anderson Lizardo <anderson.lizardo@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org, claudio.takahasi@openbossa.org
Subject: Re: [RFC v2 08/16] HoG: add report notification handler
Date: Thu, 26 Apr 2012 16:43:12 -0300 [thread overview]
Message-ID: <CAAngNMbcQLRLeiQox7MM8MOti-uCGgJETGGUT6VSnC8df=1=JQ@mail.gmail.com> (raw)
In-Reply-To: <CAJdJm_OFG4JSxrHzLY9X7uG34U-N8bD7=Rb=ZXq-t779mCc-Mw@mail.gmail.com>
2012/4/20 Anderson Lizardo <anderson.lizardo@openbossa.org>:
> Hi João,
>
> 2012/4/18 João Paulo Rechi Vita <jprvita@openbossa.org>:
>> ---
>> input/hog_device.c | 21 +++++++++++++++++++++
>> 1 files changed, 21 insertions(+), 0 deletions(-)
>>
>> diff --git a/input/hog_device.c b/input/hog_device.c
>> index ac6d4c9..5df6879 100644
>> --- a/input/hog_device.c
>> +++ b/input/hog_device.c
>> @@ -71,9 +71,27 @@ static void report_free(struct report *report)
>> g_free(report);
>> }
>>
>> +static void report_value_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
>> +{
>> + uint16_t handle;
>> +
>> + if (len < 3) {
>
> I suppose the check should be (len < 10) here ? Otherwise the DBG()
> call will read invalid data.
>
>> + error("Malformed ATT notification");
>> + return;
>> + }
>> +
>> + handle = att_get_u16(&pdu[1]);
>> +
>> + DBG("Report(0x%04x): 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x "
>> + "0x%02x", handle, pdu[2], pdu[3], pdu[4],
>> + pdu[5], pdu[6], pdu[7], pdu[8], pdu[9]);
>
> This DBG() seems strange. If handle starts at (pdu + 1) and has two
> octets, the remaining bytes should start at (pdu + 3).
>
The right thing to do here is to keep the initial check for len < 3
(1-byte opcode + 2-byte handle) and remove this debug entirely. It was
helpful during development, but normally we won't want one debug
message for every input event, even in debug mode.
--
João Paulo Rechi Vita
Openbossa Labs - INdT
next prev parent reply other threads:[~2012-04-26 19:43 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 22:08 [RFC v2 00/16] HoG plugin João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 01/16] HoG: Register HID over GATT device driver João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 02/16] HoG: register ATTIO callbacks João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 03/16] HoG: load primary service handle João Paulo Rechi Vita
2012-04-20 17:52 ` Anderson Lizardo
2012-04-26 19:42 ` Joao Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 04/16] HoG: discover all characteristics declaration João Paulo Rechi Vita
2012-04-19 1:23 ` Paulo Alcantara
2012-04-26 19:42 ` Joao Paulo Rechi Vita
2012-04-20 18:06 ` Anderson Lizardo
2012-04-26 19:42 ` Joao Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 05/16] HoG: discover descriptors for all characteristics João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 06/16] HoG: discover the "Report Map" characteristic João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 07/16] HoG: enable "Report" characteristic notification João Paulo Rechi Vita
2012-04-20 19:19 ` Anderson Lizardo
2012-04-26 19:42 ` Joao Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 08/16] HoG: add report notification handler João Paulo Rechi Vita
2012-04-20 19:23 ` Anderson Lizardo
2012-04-26 19:43 ` Joao Paulo Rechi Vita [this message]
2012-04-18 22:08 ` [RFC v2 09/16] HoG: HID I/O driver João Paulo Rechi Vita
2012-04-19 2:16 ` Paulo Alcantara
2012-04-26 19:42 ` Joao Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 10/16] HoG: Use real values for vendor and product IDs João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 11/16] GATT: Add Report Reference Descriptor declaration João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 12/16] HoG: Add read Report Reference descriptor João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 13/16] GATT: Rename Characteristic Configuration constants João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 14/16] GATT: Move GATT assigned numbers to GATT header João Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 15/16] HoG: Register only one notification callback João Paulo Rechi Vita
2012-04-20 19:31 ` Anderson Lizardo
2012-04-26 19:43 ` Joao Paulo Rechi Vita
2012-04-18 22:08 ` [RFC v2 16/16] HoG: Prepend report id to the HID report João Paulo Rechi Vita
2012-04-19 2:45 ` Paulo Alcantara
2012-04-26 19:42 ` Joao Paulo Rechi Vita
2012-04-19 7:56 ` [RFC v2 00/16] HoG plugin Johan Hedberg
2012-04-20 17:01 ` Joao Paulo Rechi Vita
2012-04-19 9:45 ` Arik Nemtsov
2012-04-20 17:06 ` Joao Paulo Rechi Vita
[not found] ` <CANtih+-ssKaFugW1Ymo49gsoq1F9YQnFfH+dNKyCT67hXh7z8A@mail.gmail.com>
2012-04-20 18:44 ` Joao Paulo Rechi Vita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAngNMbcQLRLeiQox7MM8MOti-uCGgJETGGUT6VSnC8df=1=JQ@mail.gmail.com' \
--to=jprvita@openbossa.org \
--cc=anderson.lizardo@openbossa.org \
--cc=claudio.takahasi@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).