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.hutte...@who-t.net> --- Like this? The original one is already on master and given that this isn't a functional change a follow-up is better than a revert + amend. src/XIQueryDevice.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c index c22aee1..6968d97 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); @@ -87,7 +88,9 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return) 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); + ptr += copy_classes(lib, (xXIAnyInfo*)ptr, &nclasses); + /* We skip over unused classes */ + lib->num_classes = nclasses; } Xfree(buf); -- 1.7.6 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel