summaryrefslogtreecommitdiff
path: root/Xext
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-07-06 12:20:21 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-07-14 10:14:01 +1000
commit7b9e84e320a6f6449fe7bc58a8d6a094ae37b86c (patch)
tree570039663c3361ee3b885ace9d42084d94010fe6 /Xext
parentaa19d355125a10b1a385c8f134d68e79d3d609c7 (diff)
Xext: switch to byte counting functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'Xext')
-rw-r--r--Xext/mbuf.c10
-rw-r--r--Xext/panoramiX.c4
-rw-r--r--Xext/panoramiXprocs.c18
-rw-r--r--Xext/saver.c4
-rw-r--r--Xext/security.c16
-rw-r--r--Xext/shape.c2
-rw-r--r--Xext/sync.c12
-rw-r--r--Xext/xf86bigfont.c2
-rw-r--r--Xext/xres.c4
-rw-r--r--Xext/xselinux.c6
-rw-r--r--Xext/xvdisp.c16
-rw-r--r--Xext/xvmc.c8
12 files changed, 51 insertions, 51 deletions
diff --git a/Xext/mbuf.c b/Xext/mbuf.c
index 09399b65e..55e732a9f 100644
--- a/Xext/mbuf.c
+++ b/Xext/mbuf.c
@@ -430,7 +430,7 @@ ProcCreateImageBuffers (client)
int len, nbuf, i, err, rc;
REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
- len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xMbufCreateImageBuffersReq));
if (len == 0)
return BadLength;
rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
@@ -498,7 +498,7 @@ ProcDisplayImageBuffers (client)
REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
- nbuf = stuff->length - (sizeof (xMbufDisplayImageBuffersReq) >> 2);
+ nbuf = stuff->length - bytes_to_int32(sizeof (xMbufDisplayImageBuffersReq));
if (!nbuf)
return Success;
minDelay = stuff->minDelay;
@@ -592,7 +592,7 @@ ProcSetMBufferAttributes (client)
pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
if (!pMultibuffers)
return BadMatch;
- len = stuff->length - (sizeof (xMbufSetMBufferAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof (xMbufSetMBufferAttributesReq));
vmask = stuff->valueMask;
if (len != Ones (vmask))
return BadLength;
@@ -687,7 +687,7 @@ ProcSetBufferAttributes (client)
pMultibuffer = (MultibufferPtr) LookupIDByType (stuff->buffer, MultibufferResType);
if (!pMultibuffer)
return MultibufferErrorBase + MultibufferBadBuffer;
- len = stuff->length - (sizeof (xMbufSetBufferAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof (xMbufSetBufferAttributesReq));
vmask = stuff->valueMask;
if (len != Ones (vmask))
return BadLength;
@@ -787,7 +787,7 @@ ProcGetBufferInfo (client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
- rep.length = nInfo * (sizeof (xMbufBufferInfo) >> 2);
+ rep.length = nInfo * bytes_to_int32(sizeof (xMbufBufferInfo));
rep.normalInfo = nInfo;
rep.stereoInfo = 0;
if (client->swapped)
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 4ab6f6bdd..c5fb70061 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -669,7 +669,7 @@ Bool PanoramiXCreateConnectionBlock(void)
length += (depth->nVisuals * sizeof(xVisualType));
}
- connSetupPrefix.length = length >> 2;
+ connSetupPrefix.length = bytes_to_int32(length);
for (i = 0; i < PanoramiXNumDepths; i++)
xfree(PanoramiXDepths[i].vids);
@@ -1053,7 +1053,7 @@ ProcXineramaQueryScreens(ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
- rep.length = rep.number * sz_XineramaScreenInfo >> 2;
+ rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 8b51009b3..6834efb71 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -74,7 +74,7 @@ int PanoramiXCreateWindow(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
- len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -179,7 +179,7 @@ int PanoramiXChangeWindowAttributes(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
- len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq));
if (Ones(stuff->valueMask) != len)
return BadLength;
@@ -456,7 +456,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
- len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -734,7 +734,7 @@ int PanoramiXCreateGC(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
client->errorValue = stuff->gc;
- len = client->req_len - (sizeof(xCreateGCReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -813,7 +813,7 @@ int PanoramiXChangeGC(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
- len = client->req_len - (sizeof(xChangeGCReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq));
if (Ones(stuff->mask) != len)
return BadLength;
@@ -1299,7 +1299,7 @@ int PanoramiXPolyPoint(ClientPtr client)
return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
- npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
+ npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
origPts = xalloc(npoint * sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
@@ -1359,7 +1359,7 @@ int PanoramiXPolyLine(ClientPtr client)
return (result == BadValue) ? BadGC : result;
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
- npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
+ npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0){
origPts = xalloc(npoint * sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
@@ -1605,7 +1605,7 @@ int PanoramiXFillPoly(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
- count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
+ count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0){
locPts = xalloc(count * sizeof(DDXPointRec));
memcpy((char *)locPts, (char *)&stuff[1], count * sizeof(DDXPointRec));
@@ -1895,7 +1895,7 @@ int PanoramiXGetImage(ClientPtr client)
}
- xgi.length = (length + 3) >> 2;
+ xgi.length = bytes_to_int32(length);
if (widthBytesLine == 0 || h == 0)
linesPerBuf = 0;
diff --git a/Xext/saver.c b/Xext/saver.c
index b59f769d5..06dbc7397 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -875,7 +875,7 @@ ScreenSaverSetAttributes (ClientPtr client)
if (ret != Success)
return ret;
- len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
if (!stuff->width || !stuff->height)
@@ -1267,7 +1267,7 @@ ProcScreenSaverSetAttributes (ClientPtr client)
if (status != Success)
return (status == BadValue) ? BadDrawable : status;
- len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
+ len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
diff --git a/Xext/security.c b/Xext/security.c
index bae95a3b5..8b72e179e 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -450,9 +450,9 @@ ProcSecurityGenerateAuthorization(
/* check request length */
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
- len = SIZEOF(xSecurityGenerateAuthorizationReq) >> 2;
- len += (stuff->nbytesAuthProto + (unsigned)3) >> 2;
- len += (stuff->nbytesAuthData + (unsigned)3) >> 2;
+ len = bytes_to_int32(SIZEOF(xSecurityGenerateAuthorizationReq));
+ len += bytes_to_int32(stuff->nbytesAuthProto);
+ len += bytes_to_int32(stuff->nbytesAuthData);
values = ((CARD32 *)stuff) + len;
len += Ones(stuff->valueMask);
if (client->req_len != len)
@@ -520,7 +520,7 @@ ProcSecurityGenerateAuthorization(
}
protoname = (char *)&stuff[1];
- protodata = protoname + ((stuff->nbytesAuthProto + (unsigned)3) >> 2);
+ protodata = protoname + bytes_to_int32(stuff->nbytesAuthProto);
/* call os layer to generate the authorization */
@@ -580,7 +580,7 @@ ProcSecurityGenerateAuthorization(
/* tell client the auth id and data */
rep.type = X_Reply;
- rep.length = (authdata_len + 3) >> 2;
+ rep.length = bytes_to_int32(authdata_len);
rep.sequenceNumber = client->sequence;
rep.authId = authId;
rep.dataLength = authdata_len;
@@ -688,10 +688,10 @@ SProcSecurityGenerateAuthorization(
swaps(&stuff->nbytesAuthProto, n);
swaps(&stuff->nbytesAuthData, n);
swapl(&stuff->valueMask, n);
- values_offset = ((stuff->nbytesAuthProto + (unsigned)3) >> 2) +
- ((stuff->nbytesAuthData + (unsigned)3) >> 2);
+ values_offset = bytes_to_int32(stuff->nbytesAuthProto) +
+ bytes_to_int32(stuff->nbytesAuthData);
if (values_offset >
- stuff->length - (sz_xSecurityGenerateAuthorizationReq >> 2))
+ stuff->length - bytes_to_int32(sz_xSecurityGenerateAuthorizationReq))
return BadLength;
values = (CARD32 *)(&stuff[1]) + values_offset;
nvalues = (((CARD32 *)stuff) + stuff->length) - values;
diff --git a/Xext/shape.c b/Xext/shape.c
index 5977296e5..a5ae45578 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -1069,7 +1069,7 @@ ProcShapeGetRectangles (ClientPtr client)
}
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
- rep.length = (nrects * sizeof (xRectangle)) >> 2;
+ rep.length = bytes_to_int32(nrects * sizeof (xRectangle));
rep.ordering = YXBanded;
rep.nrects = nrects;
if (client->swapped) {
diff --git a/Xext/sync.c b/Xext/sync.c
index d7ab63cd5..a38ec7b85 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -1179,7 +1179,7 @@ ProcSyncListSystemCounters(ClientPtr client)
{
char *name = SysCounterList[i]->pSysCounterInfo->name;
/* pad to 4 byte boundary */
- len += (sz_xSyncSystemCounter + strlen(name) + 3) & ~3;
+ len += pad_to_int32(sz_xSyncSystemCounter + strlen(name));
}
if (len)
@@ -1189,7 +1189,7 @@ ProcSyncListSystemCounters(ClientPtr client)
return BadAlloc;
}
- rep.length = len >> 2;
+ rep.length = bytes_to_int32(len);
if (client->swapped)
{
@@ -1223,7 +1223,7 @@ ProcSyncListSystemCounters(ClientPtr client)
pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter;
strncpy(pname_in_reply, psci->name, namelen);
walklist = (xSyncSystemCounter *) (((char *)walklist) +
- ((sz_xSyncSystemCounter + namelen + 3) & ~3));
+ pad_to_int32(sz_xSyncSystemCounter + namelen));
}
WriteToClient(client, sizeof(rep), (char *) &rep);
@@ -1600,7 +1600,7 @@ ProcSyncCreateAlarm(ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->id, client);
vmask = stuff->valueMask;
- len = client->req_len - (sizeof(xSyncCreateAlarmReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq));
/* the "extra" call to Ones accounts for the presence of 64 bit values */
if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
return BadLength;
@@ -1681,7 +1681,7 @@ ProcSyncChangeAlarm(ClientPtr client)
return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status;
vmask = stuff->valueMask;
- len = client->req_len - (sizeof(xSyncChangeAlarmReq) >> 2);
+ len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
/* the "extra" call to Ones accounts for the presence of 64 bit values */
if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
return BadLength;
@@ -1720,7 +1720,7 @@ ProcSyncQueryAlarm(ClientPtr client)
return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
rep.type = X_Reply;
- rep.length = (sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)) >> 2;
+ rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
rep.sequenceNumber = client->sequence;
pTrigger = &pAlarm->trigger;
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index 7d4c69766..9e0b5ea73 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -629,7 +629,7 @@ ProcXF86BigfontQueryFont(
return BadAlloc;
}
reply->type = X_Reply;
- reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+ reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
reply->sequenceNumber = client->sequence;
reply->minBounds = pFont->info.ink_minbounds;
reply->maxBounds = pFont->info.ink_maxbounds;
diff --git a/Xext/xres.c b/Xext/xres.c
index 5c04c1184..9dd08b113 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -75,7 +75,7 @@ ProcXResQueryClients (ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_clients = num_clients;
- rep.length = rep.num_clients * sz_xXResClient >> 2;
+ rep.length = bytes_to_int32(rep.num_clients * sz_xXResClient);
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
@@ -144,7 +144,7 @@ ProcXResQueryClientResources (ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_types = num_types;
- rep.length = rep.num_types * sz_xXResType >> 2;
+ rep.length = bytes_to_int32(rep.num_types * sz_xXResType);
if (client->swapped) {
int n;
swaps (&rep.sequenceNumber, n);
diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index 805423074..d71895174 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -1283,7 +1283,7 @@ SELinuxSendContextReply(ClientPtr client, security_id_t sid)
}
rep.type = X_Reply;
- rep.length = (len + 3) >> 2;
+ rep.length = bytes_to_int32(len);
rep.sequenceNumber = client->sequence;
rep.context_len = len;
@@ -1510,8 +1510,8 @@ SELinuxPopulateItem(SELinuxListItemRec *i, PrivateRec **privPtr, CARD32 id,
return BadValue;
i->id = id;
- i->octx_len = (strlen(i->octx) + 4) >> 2;
- i->dctx_len = (strlen(i->dctx) + 4) >> 2;
+ i->octx_len = bytes_to_int32(strlen(i->octx) + 1);
+ i->dctx_len = bytes_to_int32(strlen(i->dctx) + 1);
*size += i->octx_len + i->dctx_len + 3;
return Success;
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index fcb61e476..3bff2ece9 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -423,12 +423,12 @@ ProcXvQueryAdaptors(ClientPtr client)
pa = pxvs->pAdaptors;
while (na--)
{
- totalSize += (strlen(pa->name) + 3) & ~3;
+ totalSize += pad_to_int32(strlen(pa->name));
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
- rep.length = totalSize >> 2;
+ rep.length = bytes_to_int32(totalSize);
_WriteQueryAdaptorsReply(client, &rep);
@@ -498,11 +498,11 @@ ProcXvQueryEncodings(ClientPtr client)
totalSize = ne * sz_xvEncodingInfo;
while (ne--)
{
- totalSize += (strlen(pe->name) + 3) & ~3;
+ totalSize += pad_to_int32(strlen(pe->name));
pe++;
}
- rep.length = totalSize >> 2;
+ rep.length = bytes_to_int32(totalSize);
_WriteQueryEncodingsReply(client, &rep);
@@ -923,7 +923,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < pPort->pAdaptor->nAttributes; i++, pAtt++)
{
- rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L;
+ rep.text_size += pad_to_int32(strlen(pAtt->name) + 1);
}
rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo)
@@ -939,7 +939,7 @@ ProcXvQueryPortAttributes(ClientPtr client)
Info.flags = pAtt->flags;
Info.min = pAtt->min_value;
Info.max = pAtt->max_value;
- Info.size = (size + 3) & ~3L;
+ Info.size = pad_to_int32(size);
_WriteAttributeInfo(client, &Info);
@@ -999,7 +999,7 @@ ProcXvPutImage(ClientPtr client)
size = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
pPort, pImage, &width, &height, NULL, NULL);
size += sizeof(xvPutImageReq);
- size = (size + 3) >> 2;
+ size = bytes_to_int32(size);
if((width < stuff->width) || (height < stuff->height))
return BadValue;
@@ -1203,7 +1203,7 @@ ProcXvListImageFormats(ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num_formats = pPort->pAdaptor->nImages;
- rep.length = pPort->pAdaptor->nImages * sz_xvImageFormatInfo >> 2;
+ rep.length = bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo);
_WriteListImageFormatsReply(client, &rep);
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 879a222bd..b7bb0fc1b 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -153,7 +153,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.num = (adaptor) ? adaptor->num_surfaces : 0;
- rep.length = rep.num * sizeof(xvmcSurfaceInfo) >> 2;
+ rep.length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo));
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), (char*)&rep);
@@ -519,7 +519,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
if(surface->compatible_subpictures)
rep.num = surface->compatible_subpictures->num_xvimages;
- rep.length = rep.num * sizeof(xvImageFormatInfo) >> 2;
+ rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), (char*)&rep);
@@ -588,8 +588,8 @@ ProcXvMCGetDRInfo(ClientPtr client)
rep.major = pScreenPriv->major;
rep.minor = pScreenPriv->minor;
rep.patchLevel = pScreenPriv->patchLevel;
- rep.nameLen = (strlen(pScreenPriv->clientDriverName) + 4) >> 2;
- rep.busIDLen = (strlen(pScreenPriv->busID) + 4) >> 2;
+ rep.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1);
+ rep.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1);
rep.length = rep.nameLen + rep.busIDLen;
rep.nameLen <<=2;