summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
Diffstat (limited to 'dix')
-rw-r--r--dix/devices.c9
-rw-r--r--dix/dispatch.c56
-rw-r--r--dix/dixfonts.c12
-rw-r--r--dix/eventconvert.c10
-rw-r--r--dix/events.c4
-rw-r--r--dix/extension.c2
-rw-r--r--dix/property.c6
-rw-r--r--dix/swaprep.c4
-rw-r--r--dix/window.c4
9 files changed, 54 insertions, 53 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 9f2cb2b1e..4d006b1f2 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1532,7 +1532,7 @@ ProcSetModifierMapping(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
if (client->req_len != ((stuff->numKeyPerModifier << 1) +
- (sizeof (xSetModifierMappingReq) >> 2)))
+ bytes_to_int32(sizeof(xSetModifierMappingReq))))
return BadLength;
rep.type = X_Reply;
@@ -1591,7 +1591,7 @@ ProcChangeKeyboardMapping(ClientPtr client)
int rc;
REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
- len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq));
if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
return BadLength;
@@ -1650,7 +1650,8 @@ ProcSetPointerMapping(ClientPtr client)
REQUEST(xSetPointerMappingReq);
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
- if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
+ if (client->req_len !=
+ bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts))
return BadLength;
rep.type = X_Reply;
rep.length = 0;
@@ -2229,7 +2230,7 @@ ProcGetMotionEvents(ClientPtr client)
nEvents++;
}
}
- rep.length = nEvents * (sizeof(xTimecoord) >> 2);
+ rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord));
rep.nEvents = nEvents;
WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
if (nEvents)
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 86db92f1e..4df775d4f 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -513,7 +513,7 @@ CreateConnectionBlock(void)
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
lenofblock = sizeof(xConnSetup) +
- ((setup.nbytesVendor + 3) & ~3) +
+ pad_to_int32(setup.nbytesVendor) +
(setup.numFormats * sizeof(xPixmapFormat)) +
(setup.numRoots * sizeof(xWindowRoot));
ConnectionInfo = xalloc(lenofblock);
@@ -638,7 +638,7 @@ ProcCreateWindow(ClientPtr client)
rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
if (rc != Success)
return rc;
- len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq));
if (Ones(stuff->mask) != len)
return BadLength;
if (!stuff->width || !stuff->height)
@@ -681,7 +681,7 @@ ProcChangeWindowAttributes(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
if (rc != Success)
return rc;
- len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq));
if (len != Ones(stuff->valueMask))
return BadLength;
result = ChangeWindowAttributes(pWin,
@@ -885,7 +885,7 @@ ProcConfigureWindow(ClientPtr client)
DixManageAccess|DixSetAttrAccess);
if (rc != Success)
return rc;
- len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq));
if (Ones((Mask)stuff->mask) != len)
return BadLength;
result = ConfigureWindow(pWin, (Mask)stuff->mask, (XID *) &stuff[1],
@@ -1013,7 +1013,7 @@ ProcQueryTree(ClientPtr client)
}
reply.nChildren = numChildren;
- reply.length = (numChildren * sizeof(Window)) >> 2;
+ reply.length = bytes_to_int32(numChildren * sizeof(Window));
WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply);
if (numChildren)
@@ -1070,7 +1070,7 @@ ProcGetAtomName(ClientPtr client)
len = strlen(str);
memset(&reply, 0, sizeof(xGetAtomNameReply));
reply.type = X_Reply;
- reply.length = (len + 3) >> 2;
+ reply.length = bytes_to_int32(len);
reply.sequenceNumber = client->sequence;
reply.nameLength = len;
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
@@ -1310,7 +1310,7 @@ ProcQueryFont(ClientPtr client)
}
reply->type = X_Reply;
- reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
reply->sequenceNumber = client->sequence;
QueryFont( pFont, reply, nprotoxcistructs);
@@ -1344,7 +1344,7 @@ ProcQueryTextExtents(ClientPtr client)
if (rc != Success)
return (rc == BadValue) ? BadFont: rc;
- length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
+ length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq));
length = length << 1;
if (stuff->oddLength)
{
@@ -1512,7 +1512,7 @@ ProcCreateGC(ClientPtr client)
if (rc != Success)
return rc;
- len = client->req_len - (sizeof(xCreateGCReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq));
if (len != Ones(stuff->mask))
return BadLength;
pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error,
@@ -1537,7 +1537,7 @@ ProcChangeGC(ClientPtr client)
if (result != Success)
return result;
- len = client->req_len - (sizeof(xChangeGCReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq));
if (len != Ones(stuff->mask))
return BadLength;
@@ -1787,7 +1787,7 @@ ProcPolyPoint(ClientPtr client)
return BadValue;
}
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
- npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
+ npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint)
(*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
(xPoint *) &stuff[1]);
@@ -1810,7 +1810,7 @@ ProcPolyLine(ClientPtr client)
return BadValue;
}
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
- npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
+ npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 1)
(*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
(DDXPointPtr) &stuff[1]);
@@ -1898,7 +1898,7 @@ ProcFillPoly(ClientPtr client)
}
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
- things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
+ things = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (things)
(*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
stuff->coordMode, things,
@@ -2042,8 +2042,8 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *)&stuff[1];
lengthProto = length;
- if (((((lengthProto * stuff->height) + (unsigned)3) >> 2) +
- (sizeof(xPutImageReq) >> 2)) != client->req_len)
+ if ((bytes_to_int32(lengthProto * stuff->height) +
+ bytes_to_int32(sizeof(xPutImageReq))) != client->req_len)
return BadLength;
ReformatImage (tmpImage, lengthProto * stuff->height,
@@ -2143,7 +2143,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
*(xGetImageReply *)pBuf = xgi;
pBuf += sz_xGetImageReply;
} else {
- xgi.length = (xgi.length + 3) >> 2;
+ xgi.length = bytes_to_int32(xgi.length);
if (widthBytesLine == 0 || height == 0)
linesPerBuf = 0;
else if (widthBytesLine >= IMAGE_BUFSIZE)
@@ -2705,7 +2705,7 @@ ProcAllocColorCells (ClientPtr client)
#endif
{
accr.type = X_Reply;
- accr.length = length >> 2;
+ accr.length = bytes_to_int32(length);
accr.sequenceNumber = client->sequence;
accr.nPixels = npixels;
accr.nMasks = nmasks;
@@ -2769,7 +2769,7 @@ ProcAllocColorPlanes(ClientPtr client)
else
return rc;
}
- acpr.length = length >> 2;
+ acpr.length = bytes_to_int32(length);
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
@@ -2804,7 +2804,7 @@ ProcFreeColors(ClientPtr client)
if(pcmp->flags & AllAllocated)
return(BadAccess);
- count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
+ count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq));
rc = FreeColors(pcmp, client->index, count,
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
if (client->noClientException != Success)
@@ -2907,7 +2907,7 @@ ProcQueryColors(ClientPtr client)
xrgb *prgbs;
xQueryColorsReply qcr;
- count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
+ count = bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
prgbs = xcalloc(1, count * sizeof(xrgb));
if(!prgbs && count)
return(BadAlloc);
@@ -2924,7 +2924,7 @@ ProcQueryColors(ClientPtr client)
}
memset(&qcr, 0, sizeof(xQueryColorsReply));
qcr.type = X_Reply;
- qcr.length = (count * sizeof(xrgb)) >> 2;
+ qcr.length = bytes_to_int32(count * sizeof(xrgb));
qcr.sequenceNumber = client->sequence;
qcr.nColors = count;
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
@@ -3294,7 +3294,7 @@ ProcListHosts(ClientPtr client)
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.nHosts = nHosts;
- reply.length = len >> 2;
+ reply.length = bytes_to_int32(len);
WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
if (nHosts)
{
@@ -3427,7 +3427,7 @@ ProcGetFontPath(ClientPtr client)
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
- reply.length = (stringLens + numpaths + 3) >> 2;
+ reply.length = bytes_to_int32(stringLens + numpaths);
reply.nPaths = numpaths;
WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
@@ -3656,7 +3656,7 @@ ClientPtr NextAvailableClient(pointer ospriv)
return (ClientPtr)NULL;
}
data.reqType = 1;
- data.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
+ data.length = bytes_to_int32(sz_xReq + sz_xConnClientPrefix);
if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
{
FreeClientResources(client);
@@ -3696,8 +3696,8 @@ ProcInitialConnection(ClientPtr client)
SwapConnClientPrefix(prefix);
}
stuff->reqType = 2;
- stuff->length += ((prefix->nbytesAuthProto + (unsigned)3) >> 2) +
- ((prefix->nbytesAuthString + (unsigned)3) >> 2);
+ stuff->length += bytes_to_int32(prefix->nbytesAuthProto) +
+ bytes_to_int32(prefix->nbytesAuthString);
if (client->swapped)
{
swaps(&stuff->length, whichbyte);
@@ -3721,7 +3721,7 @@ SendConnSetup(ClientPtr client, char *reason)
csp.success = xFalse;
csp.lengthReason = strlen(reason);
- csp.length = (csp.lengthReason + (unsigned)3) >> 2;
+ csp.length = bytes_to_int32(csp.lengthReason);
csp.majorVersion = X_PROTOCOL;
csp.minorVersion = X_PROTOCOL_REVISION;
if (client->swapped)
@@ -3812,7 +3812,7 @@ ProcEstablishConnection(ClientPtr client)
prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
auth_proto = (char *)prefix + sz_xConnClientPrefix;
- auth_string = auth_proto + ((prefix->nbytesAuthProto + 3) & ~3);
+ auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto);
if ((prefix->majorVersion != X_PROTOCOL) ||
(prefix->minorVersion != X_PROTOCOL_REVISION))
reason = "Protocol version mismatch";
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 8b6e7a329..7d7ae71de 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -792,7 +792,7 @@ finish:
memset(&reply, 0, sizeof(xListFontsReply));
reply.type = X_Reply;
- reply.length = (stringLens + nnames + 3) >> 2;
+ reply.length = bytes_to_int32(stringLens + nnames);
reply.nFonts = nnames;
reply.sequenceNumber = client->sequence;
@@ -817,7 +817,7 @@ finish:
}
}
nnames = reply.nFonts;
- reply.length = (stringLens + nnames + 3) >> 2;
+ reply.length = bytes_to_int32(stringLens + nnames);
client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
(void) WriteToClient(client, stringLens + nnames, bufferStart);
@@ -1057,9 +1057,9 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
namelen = strlen(name);
}
reply->type = X_Reply;
- reply->length = (sizeof *reply - sizeof(xGenericReply) +
+ reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
pFontInfo->nprops * sizeof(xFontProp) +
- namelen + 3) >> 2;
+ namelen);
reply->sequenceNumber = client->sequence;
reply->nameLength = namelen;
reply->minBounds = pFontInfo->ink_minbounds;
@@ -1097,8 +1097,8 @@ finish:
bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
finalReply.type = X_Reply;
finalReply.sequenceNumber = client->sequence;
- finalReply.length = (sizeof(xListFontsWithInfoReply)
- - sizeof(xGenericReply)) >> 2;
+ finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
+ - sizeof(xGenericReply));
WriteSwappedDataToClient(client, length, &finalReply);
bail:
if (c->slept)
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index a65bf68da..8d9a329c1 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -389,13 +389,13 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
/* FIXME: this should just send the buttons we have, not MAX_BUTTONs. Same
* with MAX_VALUATORS below */
/* btlen is in 4 byte units */
- btlen = (((MAX_BUTTONS + 7)/8) + 3)/4;
+ btlen = bytes_to_int32(bits_to_bytes(MAX_BUTTONS));
len += btlen * 4; /* buttonmask len */
vallen = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)/sizeof(ev->valuators.mask[0]));
len += vallen * 2 * sizeof(uint32_t); /* axisvalues */
- vallen = (((MAX_VALUATORS + 7)/8) + 3)/4;
+ vallen = bytes_to_int32(bits_to_bytes(MAX_VALUATORS));
len += vallen * 4; /* valuators mask */
*xi = xcalloc(1, len);
@@ -404,7 +404,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
xde->extension = IReqCode;
xde->evtype = GetXI2Type((InternalEvent*)ev);
xde->time = ev->time;
- xde->length = (len - sizeof(xEvent) + 3)/4;
+ xde->length = bytes_to_int32(len - sizeof(xEvent));
xde->detail = ev->detail.button;
xde->root = ev->root;
xde->buttons_len = btlen;
@@ -459,7 +459,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
nvals = count_bits(ev->valuators.mask, sizeof(ev->valuators.mask)/sizeof(ev->valuators.mask[0]));
len += nvals * (2 * sizeof(uint32_t)) * 2; /* 8 byte per valuator, once
raw, once processed */
- vallen = (((MAX_VALUATORS + 7)/8) + 3)/4;
+ vallen = bytes_to_int32(bits_to_bytes(MAX_VALUATORS));
len += vallen * 4; /* valuators mask */
*xi = xcalloc(1, len);
@@ -468,7 +468,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
raw->extension = IReqCode;
raw->evtype = GetXI2Type((InternalEvent*)ev);
raw->time = ev->time;
- raw->length = (len - sizeof(xEvent) + 3)/4;
+ raw->length = bytes_to_int32(len - sizeof(xEvent));
raw->eventtype = ev->subtype;
raw->detail = ev->detail.button;
raw->deviceid = ev->deviceid;
diff --git a/dix/events.c b/dix/events.c
index 52f8b0d4d..91a083364 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4221,8 +4221,8 @@ DeviceEnterLeaveEvent(
(mode == XINotifyPassiveUngrab && type == XI_Enter))
return;
- 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(xXIEnterEvent) + btlen * 4;
event = xcalloc(1, len);
diff --git a/dix/extension.c b/dix/extension.c
index c768ccb84..fb83af148 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -324,7 +324,7 @@ ProcListExtensions(ClientPtr client)
for (j = extensions[i]->num_aliases; --j >= 0;)
total_length += strlen(extensions[i]->aliases[j]) + 1;
}
- reply.length = (total_length + 3) >> 2;
+ reply.length = bytes_to_int32(total_length);
buffer = bufptr = xalloc(total_length);
if (!buffer)
return(BadAlloc);
diff --git a/dix/property.c b/dix/property.c
index d63b8f4e0..20c18d74a 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -218,7 +218,7 @@ ProcChangeProperty(ClientPtr client)
return BadValue;
}
len = stuff->nUnits;
- if (len > ((0xffffffff - sizeof(xChangePropertyReq)) >> 2))
+ if (len > bytes_to_int32(0xffffffff - sizeof(xChangePropertyReq)))
return BadLength;
sizeInBytes = format>>3;
totalSize = len * sizeInBytes;
@@ -532,7 +532,7 @@ ProcGetProperty(ClientPtr client)
reply.bytesAfter = n - (ind + len);
reply.format = pProp->format;
- reply.length = (len + 3) >> 2;
+ reply.length = bytes_to_int32(len);
reply.nItems = len / (pProp->format / 8 );
reply.propertyType = pProp->type;
@@ -606,7 +606,7 @@ ProcListProperties(ClientPtr client)
xlpr.type = X_Reply;
xlpr.nProperties = numProps;
- xlpr.length = (numProps * sizeof(Atom)) >> 2;
+ xlpr.length = bytes_to_int32(numProps * sizeof(Atom));
xlpr.sequenceNumber = client->sequence;
WriteReplyToClient(client, sizeof(xGenericReply), &xlpr);
if (numProps)
diff --git a/dix/swaprep.c b/dix/swaprep.c
index 86242168f..12c6dbd26 100644
--- a/dix/swaprep.c
+++ b/dix/swaprep.c
@@ -731,7 +731,7 @@ SLHostsExtend(ClientPtr pClient, int size, char *buf)
int len = host->length;
char n;
swaps (&host->length, n);
- bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2);
+ bufT += sizeof (xHostEntry) + pad_to_int32(len);
}
(void)WriteToClient (pClient, size, buf);
}
@@ -1222,7 +1222,7 @@ SwapConnSetupInfo(
pInfoT += sizeof(xConnSetup);
/* Copy the vendor string */
- i = (pConnSetup->nbytesVendor + 3) & ~3;
+ i = pad_to_int32(pConnSetup->nbytesVendor);
memcpy(pInfoT, pInfo, i);
pInfo += i;
pInfoT += i;
diff --git a/dix/window.c b/dix/window.c
index 99b594b63..32e26d986 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -1457,8 +1457,8 @@ GetWindowAttributes(WindowPtr pWin, ClientPtr client, xGetWindowAttributesReply
wa->backingStore = NotUseful;
else
wa->backingStore = pWin->backingStore;
- wa->length = (sizeof(xGetWindowAttributesReply) -
- sizeof(xGenericReply)) >> 2;
+ wa->length = bytes_to_int32(sizeof(xGetWindowAttributesReply) -
+ sizeof(xGenericReply));
wa->sequenceNumber = client->sequence;
wa->backingBitPlanes = wBackingBitPlanes (pWin);
wa->backingPixel = wBackingPixel (pWin);