summaryrefslogtreecommitdiff
path: root/plugins/sixaxis.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2013-12-12 17:16:28 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2013-12-13 11:53:52 +0200
commit7dfdf3f5a06a470db20660eaf2747f25f111120b (patch)
treeb578e0ac7ec961c8d013a954d7d5625ded692a6f /plugins/sixaxis.c
parent6377731097c665669accb4dcb0849e783f34b1f1 (diff)
downloadbluez-7dfdf3f5a06a470db20660eaf2747f25f111120b.tar.gz
sixaxis: Fix device detection
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.
Diffstat (limited to 'plugins/sixaxis.c')
-rw-r--r--plugins/sixaxis.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
index 45fa1705a..1154c1534 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;
}