xkb: CheckDeviceLedFBs(): untwist parameters
It's hard to see which fields of the xkbGetDeviceInfoReply struct it's reading or writing, and that complicates further simplifications of the caller. So instead let the caller pass in the relevant fields and do the modifications on the reply structs on its own. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
cf739f7fd5
commit
031b93642b
25
xkb/xkb.c
25
xkb/xkb.c
|
@ -6194,7 +6194,11 @@ ComputeDeviceLedInfoSize(DeviceIntPtr dev,
|
||||||
static int
|
static int
|
||||||
CheckDeviceLedFBs(DeviceIntPtr dev,
|
CheckDeviceLedFBs(DeviceIntPtr dev,
|
||||||
int class,
|
int class,
|
||||||
int id, xkbGetDeviceInfoReply * rep, ClientPtr client)
|
int id,
|
||||||
|
int present,
|
||||||
|
ClientPtr client,
|
||||||
|
int *r_length,
|
||||||
|
int *r_nFBs)
|
||||||
{
|
{
|
||||||
int nFBs = 0;
|
int nFBs = 0;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
@ -6224,7 +6228,7 @@ CheckDeviceLedFBs(DeviceIntPtr dev,
|
||||||
length += SIZEOF(xkbDeviceLedsWireDesc);
|
length += SIZEOF(xkbDeviceLedsWireDesc);
|
||||||
if (!kf->xkb_sli)
|
if (!kf->xkb_sli)
|
||||||
kf->xkb_sli = XkbAllocSrvLedInfo(dev, kf, NULL, 0);
|
kf->xkb_sli = XkbAllocSrvLedInfo(dev, kf, NULL, 0);
|
||||||
length += ComputeDeviceLedInfoSize(dev, rep->present, kf->xkb_sli);
|
length += ComputeDeviceLedInfoSize(dev, present, kf->xkb_sli);
|
||||||
if (id != XkbAllXIIds)
|
if (id != XkbAllXIIds)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6242,14 +6246,14 @@ CheckDeviceLedFBs(DeviceIntPtr dev,
|
||||||
length += SIZEOF(xkbDeviceLedsWireDesc);
|
length += SIZEOF(xkbDeviceLedsWireDesc);
|
||||||
if (!lf->xkb_sli)
|
if (!lf->xkb_sli)
|
||||||
lf->xkb_sli = XkbAllocSrvLedInfo(dev, NULL, lf, 0);
|
lf->xkb_sli = XkbAllocSrvLedInfo(dev, NULL, lf, 0);
|
||||||
length += ComputeDeviceLedInfoSize(dev, rep->present, lf->xkb_sli);
|
length += ComputeDeviceLedInfoSize(dev, present, lf->xkb_sli);
|
||||||
if (id != XkbAllXIIds)
|
if (id != XkbAllXIIds)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nFBs > 0) {
|
if (nFBs > 0) {
|
||||||
rep->nDeviceLedFBs = nFBs;
|
*r_length = length;
|
||||||
rep->length += (length / 4);
|
*r_nFBs = nFBs;
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
if (classOk)
|
if (classOk)
|
||||||
|
@ -6375,7 +6379,7 @@ int
|
||||||
ProcXkbGetDeviceInfo(ClientPtr client)
|
ProcXkbGetDeviceInfo(ClientPtr client)
|
||||||
{
|
{
|
||||||
DeviceIntPtr dev;
|
DeviceIntPtr dev;
|
||||||
int status, nDeviceLedFBs;
|
int status;
|
||||||
unsigned length, nameLen;
|
unsigned length, nameLen;
|
||||||
CARD16 ledClass, ledID;
|
CARD16 ledClass, ledID;
|
||||||
unsigned wanted;
|
unsigned wanted;
|
||||||
|
@ -6455,13 +6459,18 @@ ProcXkbGetDeviceInfo(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int led_len = 0;
|
||||||
|
int nDeviceLedFBs = 0;
|
||||||
|
|
||||||
if (wanted & XkbXI_IndicatorsMask) {
|
if (wanted & XkbXI_IndicatorsMask) {
|
||||||
status = CheckDeviceLedFBs(dev, ledClass, ledID, &rep, client);
|
status = CheckDeviceLedFBs(dev, ledClass, ledID, rep.present, client, &led_len, &nDeviceLedFBs);
|
||||||
if (status != Success)
|
if (status != Success)
|
||||||
return status;
|
return status;
|
||||||
|
rep.nDeviceLedFBs = nDeviceLedFBs;
|
||||||
|
rep.length += bytes_to_int32(led_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
length = rep.length * 4;
|
length = rep.length * 4;
|
||||||
nDeviceLedFBs = rep.nDeviceLedFBs;
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
|
|
Loading…
Reference in New Issue