diff options
-rw-r--r-- | Xi/listdev.c | 11 | ||||
-rw-r--r-- | dix/devices.c | 16 |
2 files changed, 8 insertions, 19 deletions
diff --git a/Xi/listdev.c b/Xi/listdev.c index 91e8f2254..02d55ad4c 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -96,7 +96,7 @@ int ProcXListInputDevices(register ClientPtr client) { xListInputDevicesReply rep; - int numdevs; + int numdevs = 0; int namesize = 1; /* need 1 extra byte for strcpy */ int size = 0; int total_length; @@ -115,12 +115,15 @@ ProcXListInputDevices(register ClientPtr client) rep.sequenceNumber = client->sequence; AddOtherInputDevices(); - numdevs = inputInfo.numDevices; - for (d = inputInfo.devices; d; d = d->next) + for (d = inputInfo.devices; d; d = d->next) { SizeDeviceInfo(d, &namesize, &size); - for (d = inputInfo.off_devices; d; d = d->next) + numdevs++; + } + for (d = inputInfo.off_devices; d; d = d->next) { SizeDeviceInfo(d, &namesize, &size); + numdevs++; + } total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; devbuf = (char *)xalloc(total_length); diff --git a/dix/devices.c b/dix/devices.c index 1d423e273..69f1e7bcc 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -536,7 +536,7 @@ RemoveDevice(DeviceIntPtr dev) ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer); #endif - if (!dev) + if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer) return BadImplementation; prev = NULL; @@ -550,13 +550,6 @@ RemoveDevice(DeviceIntPtr dev) else prev->next = next; - inputInfo.numDevices--; - - if (inputInfo.keyboard == tmp) - inputInfo.keyboard = NULL; - else if (inputInfo.pointer == tmp) - inputInfo.pointer = NULL; - ret = Success; } } @@ -572,13 +565,6 @@ RemoveDevice(DeviceIntPtr dev) else prev->next = next; - inputInfo.numDevices--; - - if (inputInfo.keyboard == tmp) - inputInfo.keyboard = NULL; - else if (inputInfo.pointer == tmp) - inputInfo.pointer = NULL; - ret = Success; } } |