[PATCH libXi] Use a separate nclasses variable in XIQueryDevice

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 22 16:08:02 PDT 2011


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 at 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



More information about the xorg-devel mailing list