diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-09-23 09:04:21 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-09-28 11:13:46 +1000 |
commit | 5f9df47340e192d095127e3c7da180b0fb3dc286 (patch) | |
tree | 36f46ae2d8b4d66cbc058e05f14872dc0452fadc /src | |
parent | 2eb34db82dbd8429594c7ce1d361cabf3571edf1 (diff) |
Use a separate nclasses variable in XIQueryDevice
No functional changes, just clarifying the code. If we skip over unknown
classes, lib->num_classes != wire->num_classe. Use a separate variable to
make that change more explicit and align the code closer with
wireToDeviceChangedEvent.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/XIQueryDevice.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c index c22aee1..464ab4d 100644 --- a/src/XIQueryDevice.c +++ b/src/XIQueryDevice.c @@ -70,6 +70,7 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) for (i = 0; i < reply.num_devices; i++) { + int nclasses; XIDeviceInfo *lib = &info[i]; xXIDeviceInfo *wire = (xXIDeviceInfo*)ptr; @@ -77,8 +78,8 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) lib->use = wire->use; lib->attachment = wire->attachment; lib->enabled = wire->enabled; - lib->num_classes = wire->num_classes; lib->classes = (XIAnyClassInfo**)&lib[1]; + nclasses = wire->num_classes; ptr += sizeof(xXIDeviceInfo); @@ -86,8 +87,10 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) strncpy(lib->name, ptr, wire->name_len); ptr += ((wire->name_len + 3)/4) * 4; - lib->classes = Xmalloc(size_classes((xXIAnyInfo*)ptr, lib->num_classes)); - ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &lib->num_classes); + lib->classes = Xmalloc(size_classes((xXIAnyInfo*)ptr, nclasses)); + ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &nclasses); + /* We skip over unused classes */ + lib->num_classes = nclasses; } Xfree(buf); |