From: Bastien Nocera <hadess@hadess.net>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] sixaxis: Fix device detection
Date: Thu, 12 Dec 2013 17:16:28 +0100 [thread overview]
Message-ID: <1386864988.1982.45.camel@nuvo> (raw)
After searching past the end of the structure, the loop sometimes
found matches in the daemon's address space...
This fixes the loop to end after the elements have been exhausted.
---
plugins/sixaxis.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 45fa170..1154c15 100644
--- a/plugins/sixaxis.c
+++ b/plugins/sixaxis.c
@@ -301,7 +301,7 @@ static int get_supported_device(struct udev_device *udevice, uint16_t *bus)
struct udev_device *hid_parent;
uint16_t vid, pid;
const char *hid_id;
- int i;
+ guint i;
hid_parent = udev_device_get_parent_with_subsystem_devtype(udevice,
"hid", NULL);
@@ -313,7 +313,7 @@ static int get_supported_device(struct udev_device *udevice, uint16_t *bus)
if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3)
return -1;
- for (i = 0; G_N_ELEMENTS(devices); i++) {
+ for (i = 0; i < G_N_ELEMENTS(devices); i++) {
if (devices[i].vid == vid && devices[i].pid == pid)
return i;
}
--
1.8.4.2
next reply other threads:[~2013-12-12 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 16:16 Bastien Nocera [this message]
2013-12-13 9:54 ` [PATCH] sixaxis: Fix device detection Johan Hedberg
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=1386864988.1982.45.camel@nuvo \
--to=hadess@hadess.net \
--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