From: Marcel Holtmann <marcel@holtmann.org>
To: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] [PATCH] Fix too-many-keys-pressed error in hidp/core.c
Date: Sun, 23 Jan 2005 13:01:33 +0100 [thread overview]
Message-ID: <1106481693.9269.6.camel@pegasus> (raw)
In-Reply-To: <20050123113924.GA17069@salvia.homeip.net>
[-- Attachment #1: Type: text/plain, Size: 750 bytes --]
Hi Juha,
> > I think we should add a patch for this, but I don't like the way you did
> > it. Checking for the end value of a for-loop is not a good programming
> > practice. Using memcmp() here should be a lot better and cleaner.
>
> It depends on how you think about the problem. If you see the data as just
> an array of bytes, memcmp() is the way to go. If you think of it as 6
> consecutive key codes, with each one set to 1, for loop is conceptually the
> right thing to use.
I don't see your difference. We have to match a specific case and we
have to do it with clean code. And as I said, checking the end value of
a for-loop is not good code for me. So I am using memcmp() for it and my
patch is attached.
Regards
Marcel
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 860 bytes --]
===== net/bluetooth/hidp/core.c 1.3 vs edited =====
--- 1.3/net/bluetooth/hidp/core.c 2004-12-26 19:19:32 +01:00
+++ edited/net/bluetooth/hidp/core.c 2005-01-23 10:01:48 +01:00
@@ -74,6 +74,8 @@
150,158,159,128,136,177,178,176,142,152,173,140
};
+static unsigned char hidp_mkeyspat[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
+
static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr)
{
struct hidp_session *session;
@@ -174,6 +176,11 @@
case 0x01: /* Keyboard report */
for (i = 0; i < 8; i++)
input_report_key(dev, hidp_keycode[i + 224], (udata[0] >> i) & 1);
+
+ /* If all the key codes have been set to 0x01, it means
+ * too many keys were pressed at the same time. */
+ if (!memcmp(udata + 2, hidp_mkeyspat, 6))
+ break;
for (i = 2; i < 8; i++) {
if (keys[i] > 3 && memscan(udata + 2, keys[i], 6) == udata + 8) {
prev parent reply other threads:[~2005-01-23 12:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-19 22:44 [Bluez-devel] [PATCH] Fix too-many-keys-pressed error in hidp/core.c Juha Yrjölä
2005-01-20 0:19 ` Marcel Holtmann
2005-01-20 0:34 ` Juha Yrjölä
2005-01-20 1:01 ` Marcel Holtmann
2005-01-20 9:03 ` Juha Yrjölä
2005-01-23 8:46 ` Marcel Holtmann
2005-01-23 11:39 ` Juha Yrjölä
2005-01-23 12:01 ` Marcel Holtmann [this message]
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=1106481693.9269.6.camel@pegasus \
--to=marcel@holtmann.org \
--cc=bluez-devel@lists.sourceforge.net \
/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