summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xi/chgdctl.c6
-rw-r--r--Xi/chgfctl.c14
-rw-r--r--Xi/chgkmap.c2
-rw-r--r--Xi/chgprop.c2
-rw-r--r--Xi/exevents.c10
-rw-r--r--Xi/getbmap.c2
-rw-r--r--Xi/getdctl.c2
-rw-r--r--Xi/getfctl.c2
-rw-r--r--Xi/getprop.c2
-rw-r--r--Xi/getselev.c2
-rw-r--r--Xi/getvers.c4
-rw-r--r--Xi/grabdev.c4
-rw-r--r--Xi/grabdevb.c2
-rw-r--r--Xi/grabdevk.c2
-rw-r--r--Xi/gtmotion.c2
-rw-r--r--Xi/listdev.c2
-rw-r--r--Xi/opendev.c2
-rw-r--r--Xi/queryst.c2
-rw-r--r--Xi/selectev.c2
-rw-r--r--Xi/sendexev.c8
-rw-r--r--Xi/setbmap.c4
-rw-r--r--Xi/setdval.c2
-rw-r--r--Xi/setmmap.c4
-rw-r--r--Xi/xichangehierarchy.c2
-rw-r--r--Xi/xiproperty.c8
-rw-r--r--Xi/xiquerydevice.c13
-rw-r--r--Xi/xiquerypointer.c2
-rw-r--r--Xi/xiselectev.c2
28 files changed, 56 insertions, 55 deletions
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index 89e5a2d93..901a0e419 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -142,7 +142,7 @@ ProcXChangeDeviceControl(ClientPtr client)
REQUEST(xChangeDeviceControlReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
- len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq));
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
goto out;
@@ -155,8 +155,8 @@ ProcXChangeDeviceControl(ClientPtr client)
switch (stuff->control) {
case DEVICE_RESOLUTION:
r = (xDeviceResolutionCtl *) & stuff[1];
- if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
- (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
+ if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) ||
+ (len != bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) {
ret = BadLength;
goto out;
}
diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
index e193e1384..9189702c1 100644
--- a/Xi/chgfctl.c
+++ b/Xi/chgfctl.c
@@ -441,14 +441,14 @@ ProcXChangeFeedbackControl(ClientPtr client)
REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
- len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xChangeFeedbackControlReq));
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (rc != Success)
return rc;
switch (stuff->feedbackid) {
case KbdFeedbackClass:
- if (len != (sizeof(xKbdFeedbackCtl) >> 2))
+ if (len != bytes_to_int32(sizeof(xKbdFeedbackCtl)))
return BadLength;
for (k = dev->kbdfeed; k; k = k->next)
@@ -457,7 +457,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
(xKbdFeedbackCtl *) & stuff[1]);
break;
case PtrFeedbackClass:
- if (len != (sizeof(xPtrFeedbackCtl) >> 2))
+ if (len != bytes_to_int32(sizeof(xPtrFeedbackCtl)))
return BadLength;
for (p = dev->ptrfeed; p; p = p->next)
@@ -473,7 +473,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
if (client->swapped) {
swaps(&f->num_keysyms, n);
}
- if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms))
+ if (len != (bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms))
return BadLength;
for (s = dev->stringfeed; s; s = s->next)
@@ -483,7 +483,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
break;
}
case IntegerFeedbackClass:
- if (len != (sizeof(xIntegerFeedbackCtl) >> 2))
+ if (len != bytes_to_int32(sizeof(xIntegerFeedbackCtl)))
return BadLength;
for (i = dev->intfeed; i; i = i->next)
@@ -492,7 +492,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
(xIntegerFeedbackCtl *)&stuff[1]);
break;
case LedFeedbackClass:
- if (len != (sizeof(xLedFeedbackCtl) >> 2))
+ if (len != bytes_to_int32(sizeof(xLedFeedbackCtl)))
return BadLength;
for (l = dev->leds; l; l = l->next)
@@ -501,7 +501,7 @@ ProcXChangeFeedbackControl(ClientPtr client)
(xLedFeedbackCtl *) & stuff[1]);
break;
case BellFeedbackClass:
- if (len != (sizeof(xBellFeedbackCtl) >> 2))
+ if (len != bytes_to_int32(sizeof(xBellFeedbackCtl)))
return BadLength;
for (b = dev->bell; b; b = b->next)
diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c
index 854c17f3b..e4b9e154c 100644
--- a/Xi/chgkmap.c
+++ b/Xi/chgkmap.c
@@ -107,7 +107,7 @@ ProcXChangeDeviceKeyMapping(ClientPtr client)
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
if (ret != Success)
return ret;
- len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceKeyMappingReq));
ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify,
stuff->firstKeyCode, stuff->keyCodes,
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index d8e37a7c7..d24a24638 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -104,7 +104,7 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client)
REQUEST(xChangeDeviceDontPropagateListReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
- if (stuff->length != (sizeof(xChangeDeviceDontPropagateListReq) >> 2) +
+ if (stuff->length != bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) +
stuff->count)
return BadLength;
diff --git a/Xi/exevents.c b/Xi/exevents.c
index c575bb42a..85baa03a9 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -686,7 +686,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged
{
len += sizeof(xXIButtonInfo);
len += dce->buttons.num_buttons * sizeof(Atom); /* button names */
- len += ((((dce->buttons.num_buttons + 7)/8) + 3)/4) * 4;
+ len += pad_to_int32(bits_to_bytes(dce->buttons.num_buttons));
}
if (dce->num_valuators)
len += sizeof(xXIValuatorInfo) * dce->num_valuators;
@@ -714,7 +714,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged
dcce->sourceid = device->id;
dcce->reason = (dce->flags & DEVCHANGE_DEVICE_CHANGE) ? XIDeviceChange : XISlaveSwitch;
dcce->num_classes = 0;
- dcce->length = (len - sizeof(xEvent))/4;
+ dcce->length = bytes_to_int32(len - sizeof(xEvent));
ptr = (char*)&dcce[1];
if (dce->buttons.num_buttons)
@@ -1249,15 +1249,15 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
mouse = (IsMaster(dev) || dev->u.master) ? GetMaster(dev, MASTER_POINTER) : dev;
/* XI 2 event */
- btlen = (mouse->button) ? (mouse->button->numButtons + 7)/8 : 0;
- btlen = (btlen + 3)/4;
+ btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
+ btlen = bytes_to_int32(btlen);
len = sizeof(xXIFocusInEvent) + btlen * 4;
xi2event = xcalloc(1, len);
xi2event->type = GenericEvent;
xi2event->extension = IReqCode;
xi2event->evtype = type;
- xi2event->length = (len - sizeof(xEvent))/4;
+ xi2event->length = bytes_to_int32(len - sizeof(xEvent));
xi2event->buttons_len = btlen;
xi2event->detail = detail;
xi2event->time = currentTime.milliseconds;
diff --git a/Xi/getbmap.c b/Xi/getbmap.c
index 4a788c66b..e2d58972a 100644
--- a/Xi/getbmap.c
+++ b/Xi/getbmap.c
@@ -109,7 +109,7 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
return BadMatch;
rep.nElts = b->numButtons;
- rep.length = (rep.nElts + (4 - 1)) / 4;
+ rep.length = bytes_to_int32(rep.nElts);
WriteReplyToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep);
(void)WriteToClient(client, rep.nElts, (char *)&b->map[1]);
return Success;
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index abb4f9935..68181fa61 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -306,7 +306,7 @@ ProcXGetDeviceControl(ClientPtr client)
break;
}
- rep.length = (total_length + 3) >> 2;
+ rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep);
WriteToClient(client, total_length, savbuf);
xfree(savbuf);
diff --git a/Xi/getfctl.c b/Xi/getfctl.c
index 3a6dd4585..607765e98 100644
--- a/Xi/getfctl.c
+++ b/Xi/getfctl.c
@@ -358,7 +358,7 @@ ProcXGetFeedbackControl(ClientPtr client)
for (b = dev->bell; b; b = b->next)
CopySwapBellFeedback(client, b, &buf);
- rep.length = (total_length + 3) >> 2;
+ rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep);
WriteToClient(client, total_length, savbuf);
xfree(savbuf);
diff --git a/Xi/getprop.c b/Xi/getprop.c
index dfa27f5cc..1f28a8a40 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -120,7 +120,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
if (count) {
rep.count = count;
buf = (XEventClass *) xalloc(rep.count * sizeof(XEventClass));
- rep.length = (rep.count * sizeof(XEventClass) + 3) >> 2;
+ rep.length = bytes_to_int32(rep.count * sizeof(XEventClass));
tbuf = buf;
for (i = 0; i < EMASKSIZE; i++)
diff --git a/Xi/getselev.c b/Xi/getselev.c
index ea9bd9ba5..90f6284e5 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -131,7 +131,7 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
total_length = (rep.all_clients_count + rep.this_client_count) *
sizeof(XEventClass);
- rep.length = (total_length + 3) >> 2;
+ rep.length = bytes_to_int32(total_length);
buf = (XEventClass *) xalloc(total_length);
tclient = buf;
diff --git a/Xi/getvers.c b/Xi/getvers.c
index c8eacc172..c8e9ebca6 100644
--- a/Xi/getvers.c
+++ b/Xi/getvers.c
@@ -96,8 +96,8 @@ ProcXGetExtensionVersion(ClientPtr client)
REQUEST(xGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xGetExtensionVersionReq);
- if (stuff->length != (sizeof(xGetExtensionVersionReq) +
- stuff->nbytes + 3) >> 2)
+ if (stuff->length != bytes_to_int32(sizeof(xGetExtensionVersionReq) +
+ stuff->nbytes))
return BadLength;
memset(&rep, 0, sizeof(xGetExtensionVersionReply));
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index e1d430a1f..a7e46fe34 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -84,7 +84,7 @@ SProcXGrabDevice(ClientPtr client)
swapl(&stuff->time, n);
swaps(&stuff->event_count, n);
- if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count)
+ if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
@@ -110,7 +110,7 @@ ProcXGrabDevice(ClientPtr client)
REQUEST(xGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceReq);
- if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count)
+ if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count)
return BadLength;
rep.repType = X_Reply;
diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c
index 58fb73bca..e235f5313 100644
--- a/Xi/grabdevb.c
+++ b/Xi/grabdevb.c
@@ -110,7 +110,7 @@ ProcXGrabDeviceButton(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
if (stuff->length !=
- (sizeof(xGrabDeviceButtonReq) >> 2) + stuff->event_count)
+ bytes_to_int32(sizeof(xGrabDeviceButtonReq)) + stuff->event_count)
return BadLength;
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c
index 9ae38f0f1..b34867b5f 100644
--- a/Xi/grabdevk.c
+++ b/Xi/grabdevk.c
@@ -107,7 +107,7 @@ ProcXGrabDeviceKey(ClientPtr client)
REQUEST(xGrabDeviceKeyReq);
REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq);
- if (stuff->length != (sizeof(xGrabDeviceKeyReq) >> 2) + stuff->event_count)
+ if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count)
return BadLength;
ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c
index 55d45a363..8e91c5a47 100644
--- a/Xi/gtmotion.c
+++ b/Xi/gtmotion.c
@@ -136,7 +136,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
(ScreenPtr) NULL, FALSE);
}
if (rep.nEvents > 0) {
- length = (rep.nEvents * size + 3) >> 2;
+ length = bytes_to_int32(rep.nEvents * size);
rep.length = length;
}
nEvents = rep.nEvents;
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 1c847fbeb..563fc0773 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -409,7 +409,7 @@ ProcXListInputDevices(ClientPtr client)
ListDeviceInfo(client, d, dev++, &devbuf, &classbuf, &namebuf);
}
rep.ndevices = numdevs;
- rep.length = (total_length + 3) >> 2;
+ rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep);
WriteToClient(client, total_length, savbuf);
xfree(savbuf);
diff --git a/Xi/opendev.c b/Xi/opendev.c
index 46d55a820..3844d25a2 100644
--- a/Xi/opendev.c
+++ b/Xi/opendev.c
@@ -150,7 +150,7 @@ ProcXOpenDevice(ClientPtr client)
}
evbase[j].class = OtherClass;
evbase[j++].event_type_base = event_base[OtherClass];
- rep.length = (j * sizeof(xInputClassInfo) + 3) >> 2;
+ rep.length = bytes_to_int32(j * sizeof(xInputClassInfo));
rep.num_classes = j;
WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep);
WriteToClient(client, j * sizeof(xInputClassInfo), (char *)evbase);
diff --git a/Xi/queryst.c b/Xi/queryst.c
index c6858e4e0..60ec32ec9 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -161,7 +161,7 @@ ProcXQueryDeviceState(ClientPtr client)
}
rep.num_classes = num_classes;
- rep.length = (total_length + 3) >> 2;
+ rep.length = bytes_to_int32(total_length);
WriteReplyToClient(client, sizeof(xQueryDeviceStateReply), &rep);
if (total_length > 0)
WriteToClient(client, total_length, savbuf);
diff --git a/Xi/selectev.c b/Xi/selectev.c
index 013fdc930..031e602ad 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -154,7 +154,7 @@ ProcXSelectExtensionEvent(ClientPtr client)
REQUEST(xSelectExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
- if (stuff->length != (sizeof(xSelectExtensionEventReq) >> 2) + stuff->count)
+ if (stuff->length != bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count)
return BadLength;
ret = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index 63b45ee49..8629dd202 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -89,8 +89,8 @@ SProcXSendExtensionEvent(ClientPtr client)
swapl(&stuff->destination, n);
swaps(&stuff->count, n);
- if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count +
- (stuff->num_events * (sizeof(xEvent) >> 2)))
+ if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
+ bytes_to_int32(stuff->num_events * sizeof(xEvent)))
return BadLength;
eventP = (xEvent *) & stuff[1];
@@ -126,8 +126,8 @@ ProcXSendExtensionEvent(ClientPtr client)
REQUEST(xSendExtensionEventReq);
REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
- if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count +
- (stuff->num_events * (sizeof(xEvent) >> 2)))
+ if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count +
+ (stuff->num_events * bytes_to_int32(sizeof(xEvent))))
return BadLength;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess);
diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index e7b8d4ac0..37c40e408 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -94,8 +94,8 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
REQUEST(xSetDeviceButtonMappingReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceButtonMappingReq);
- if (stuff->length != (sizeof(xSetDeviceButtonMappingReq) +
- stuff->map_length + 3) >> 2)
+ if (stuff->length !=
+ bytes_to_int32(sizeof(xSetDeviceButtonMappingReq) + stuff->map_length))
return BadLength;
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
diff --git a/Xi/setdval.c b/Xi/setdval.c
index fe5f31691..b384f0d3c 100644
--- a/Xi/setdval.c
+++ b/Xi/setdval.c
@@ -100,7 +100,7 @@ ProcXSetDeviceValuators(ClientPtr client)
rep.status = Success;
rep.sequenceNumber = client->sequence;
- if (stuff->length != (sizeof(xSetDeviceValuatorsReq) >> 2) +
+ if (stuff->length != bytes_to_int32(sizeof(xSetDeviceValuatorsReq)) +
stuff->num_valuators)
return BadLength;
diff --git a/Xi/setmmap.c b/Xi/setmmap.c
index ffcc7f3ce..cbe5dc8c5 100644
--- a/Xi/setmmap.c
+++ b/Xi/setmmap.c
@@ -96,8 +96,8 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
REQUEST(xSetDeviceModifierMappingReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
- if (stuff->length != ((sizeof(xSetDeviceModifierMappingReq) >> 2) +
- (stuff->numKeyPerModifier << 1)))
+ if (stuff->length != bytes_to_int32(sizeof(xSetDeviceModifierMappingReq)) +
+ (stuff->numKeyPerModifier << 1))
return BadLength;
rep.repType = X_Reply;
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index 656515bfd..9f52b6dbe 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -112,7 +112,7 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES])
}
}
- ev->length = (ev->num_info * sizeof(xXIHierarchyInfo))/4;
+ ev->length = bytes_to_int32(ev->num_info * sizeof(xXIHierarchyInfo));
dummyDev.id = XIAllDevices;
SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), (xEvent*)ev, 1);
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 55f20c402..0a47e31ee 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -903,7 +903,7 @@ ProcXChangeDeviceProperty (ClientPtr client)
stuff->format, stuff->mode, stuff->nUnits);
len = stuff->nUnits;
- if (len > ((0xffffffff - sizeof(xChangeDevicePropertyReq)) >> 2))
+ if (len > (bytes_to_int32(0xffffffff - sizeof(xChangeDevicePropertyReq))))
return BadLength;
totalSize = len * (stuff->format/8);
@@ -972,7 +972,7 @@ ProcXGetDeviceProperty (ClientPtr client)
reply.format = format;
reply.bytesAfter = bytes_after;
reply.propertyType = type;
- reply.length = (length + 3) >> 2;
+ reply.length = bytes_to_int32(length);
if (stuff->delete && (reply.bytesAfter == 0))
send_property_event(dev, stuff->property, XIPropertyDeleted);
@@ -1146,7 +1146,7 @@ ProcXIChangeProperty(ClientPtr client)
rc = check_change_property(client, stuff->property, stuff->type,
stuff->format, stuff->mode, stuff->num_items);
len = stuff->num_items;
- if (len > ((0xffffffff - sizeof(xXIChangePropertyReq)) >> 2))
+ if (len > bytes_to_int32(0xffffffff - sizeof(xXIChangePropertyReq)))
return BadLength;
totalSize = len * (stuff->format/8);
@@ -1215,7 +1215,7 @@ ProcXIGetProperty(ClientPtr client)
reply.format = format;
reply.bytes_after = bytes_after;
reply.type = type;
- reply.length = (length + 3)/4;
+ reply.length = bytes_to_int32(length);
if (length && stuff->delete && (reply.bytes_after == 0))
send_property_event(dev, stuff->property, XIPropertyDeleted);
diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 33628a6ef..68d91fa87 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -200,7 +200,7 @@ SizeDeviceInfo(DeviceIntPtr dev)
int len = sizeof(xXIDeviceInfo);
/* 4-padded name */
- len += (((strlen(dev->name) + 3)/4)*4);
+ len += pad_to_int32(strlen(dev->name));
return len + SizeDeviceClasses(dev);
@@ -218,7 +218,7 @@ SizeDeviceClasses(DeviceIntPtr dev)
{
len += sizeof(xXIButtonInfo);
len += dev->button->numButtons * sizeof(Atom);
- len += ((((dev->button->numButtons + 7)/8) + 3)/4) * 4;
+ len += pad_to_int32(bits_to_bytes(dev->button->numButtons));
}
if (dev->key)
@@ -246,11 +246,12 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info)
int mask_len;
int i;
- mask_len = (((dev->button->numButtons + 7)/8) + 3)/4; /* 4-byte units*/
+ mask_len = bytes_to_int32(bits_to_bytes(dev->button->numButtons));
info->type = ButtonClass;
info->num_buttons = dev->button->numButtons;
- info->length = sizeof(xXIButtonInfo)/4 + mask_len + info->num_buttons;
+ info->length = bytes_to_int32(sizeof(xXIButtonInfo)) +
+ info->num_buttons + mask_len;
info->sourceid = dev->button->sourceid;
bits = (unsigned char*)&info[1];
@@ -400,7 +401,7 @@ ListDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info)
info->enabled = dev->enabled;
total_len = sizeof(xXIDeviceInfo);
- len = ((info->name_len + 3)/4) * 4;
+ len = pad_to_int32(info->name_len);
memset(any, 0, len);
strncpy(any, dev->name, info->name_len);
any += len;
@@ -456,7 +457,7 @@ SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info)
int i;
/* Skip over name */
- any += (((info->name_len + 3)/4) * 4);
+ any += pad_to_int32(info->name_len);
for (i = 0; i < info->num_classes; i++)
{
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 2222873aa..da1d101cb 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -126,7 +126,7 @@ ProcXIQueryPointer(ClientPtr client)
if (pDev->button)
{
int i, down;
- rep.buttons_len = (((pDev->button->numButtons + 7)/8) + 3)/4;
+ rep.buttons_len = bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
rep.length += rep.buttons_len;
buttons = xcalloc(rep.buttons_len, 4);
if (!buttons)
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 750ae61cc..2baae77f6 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -196,7 +196,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
return Success;
}
- buffer = xcalloc(MAXDEVICES, sizeof(xXIEventMask) + ((XI2MASKSIZE + 3)/4) * 4);
+ buffer = xcalloc(MAXDEVICES, sizeof(xXIEventMask) + pad_to_int32(XI2MASKSIZE));
if (!buffer)
return BadAlloc;