randr: switch to byte counting functions
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
7b9e84e320
commit
86b239ff9c
|
@ -775,7 +775,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
|
|||
int rc, i, j;
|
||||
|
||||
REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
|
||||
numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2));
|
||||
numOutputs = (stuff->length - bytes_to_int32(SIZEOF (xRRSetCrtcConfigReq)));
|
||||
|
||||
VERIFY_RR_CRTC(stuff->crtc, crtc, DixSetAttrAccess);
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ ProcRRGetCrtcGamma (ClientPtr client)
|
|||
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
reply.length = (len + 3) >> 2;
|
||||
reply.length = bytes_to_int32(len);
|
||||
reply.size = crtc->gammaSize;
|
||||
if (client->swapped) {
|
||||
swaps (&reply.sequenceNumber, n);
|
||||
|
@ -1234,7 +1234,7 @@ ProcRRSetCrtcGamma (ClientPtr client)
|
|||
REQUEST_AT_LEAST_SIZE(xRRSetCrtcGammaReq);
|
||||
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
|
||||
|
||||
len = client->req_len - (sizeof (xRRSetCrtcGammaReq) >> 2);
|
||||
len = client->req_len - bytes_to_int32(sizeof (xRRSetCrtcGammaReq));
|
||||
if (len < (stuff->size * 3 + 1) >> 1)
|
||||
return BadLength;
|
||||
|
||||
|
@ -1274,7 +1274,7 @@ ProcRRSetCrtcTransform (ClientPtr client)
|
|||
|
||||
filter = (char *) (stuff + 1);
|
||||
nbytes = stuff->nbytesFilter;
|
||||
params = (xFixed *) (filter + ((nbytes + 3) & ~3));
|
||||
params = (xFixed *) (filter + pad_to_int32(nbytes));
|
||||
nparams = ((xFixed *) stuff + client->req_len) - params;
|
||||
if (nparams < 0)
|
||||
return BadLength;
|
||||
|
@ -1295,7 +1295,7 @@ transform_filter_length (RRTransformPtr transform)
|
|||
return 0;
|
||||
nbytes = strlen (transform->filter->name);
|
||||
nparams = transform->nparams;
|
||||
return ((nbytes + 3) & ~3) + (nparams * sizeof (xFixed));
|
||||
return pad_to_int32(nbytes) + (nparams * sizeof (xFixed));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1334,7 +1334,7 @@ transform_encode (ClientPtr client, xRenderTransform *wire, PictTransform *pict)
|
|||
{
|
||||
xRenderTransform_from_PictTransform (wire, pict);
|
||||
if (client->swapped)
|
||||
SwapLongs ((CARD32 *) wire, sizeof (xRenderTransform) >> 2);
|
||||
SwapLongs ((CARD32 *) wire, bytes_to_int32(sizeof(xRenderTransform)));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1363,7 +1363,7 @@ ProcRRGetCrtcTransform (ClientPtr client)
|
|||
extra = (char *) (reply + 1);
|
||||
reply->type = X_Reply;
|
||||
reply->sequenceNumber = client->sequence;
|
||||
reply->length = (CrtcTransformExtra + nextra) >> 2;
|
||||
reply->length = bytes_to_int32(CrtcTransformExtra + nextra);
|
||||
|
||||
reply->hasTransforms = crtc->transforms;
|
||||
|
||||
|
|
|
@ -297,10 +297,10 @@ ProcRRCreateMode (ClientPtr client)
|
|||
|
||||
modeInfo = &stuff->modeInfo;
|
||||
name = (char *) (stuff + 1);
|
||||
units_after = (stuff->length - (sizeof (xRRCreateModeReq) >> 2));
|
||||
units_after = (stuff->length - bytes_to_int32(sizeof (xRRCreateModeReq)));
|
||||
|
||||
/* check to make sure requested name fits within the data provided */
|
||||
if ((int) (modeInfo->nameLength + 3) >> 2 > units_after)
|
||||
if (bytes_to_int32(modeInfo->nameLength) > units_after)
|
||||
return BadLength;
|
||||
|
||||
mode = RRModeCreateUser (pScreen, modeInfo, name, &error);
|
||||
|
|
|
@ -455,7 +455,7 @@ ProcRRGetOutputInfo (ClientPtr client)
|
|||
|
||||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.length = OutputInfoExtra >> 2;
|
||||
rep.length = bytes_to_int32(OutputInfoExtra);
|
||||
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
|
||||
rep.crtc = output->crtc ? output->crtc->id : None;
|
||||
rep.mmWidth = output->mmWidth;
|
||||
|
@ -471,11 +471,11 @@ ProcRRGetOutputInfo (ClientPtr client)
|
|||
extraLen = ((output->numCrtcs +
|
||||
output->numModes + output->numUserModes +
|
||||
output->numClones +
|
||||
((rep.nameLength + 3) >> 2)) << 2);
|
||||
bytes_to_int32(rep.nameLength)) << 2);
|
||||
|
||||
if (extraLen)
|
||||
{
|
||||
rep.length += extraLen >> 2;
|
||||
rep.length += bytes_to_int32(extraLen);
|
||||
extra = xalloc (extraLen);
|
||||
if (!extra)
|
||||
return BadAlloc;
|
||||
|
|
|
@ -429,7 +429,7 @@ ProcRRListOutputProperties (ClientPtr client)
|
|||
return(BadAlloc);
|
||||
|
||||
rep.type = X_Reply;
|
||||
rep.length = (numProps * sizeof(Atom)) >> 2;
|
||||
rep.length = bytes_to_int32(numProps * sizeof(Atom));
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.nAtoms = numProps;
|
||||
if (client->swapped)
|
||||
|
@ -510,7 +510,7 @@ ProcRRConfigureOutputProperty (ClientPtr client)
|
|||
|
||||
VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
|
||||
|
||||
num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2);
|
||||
num_valid = stuff->length - bytes_to_int32(sizeof (xRRConfigureOutputPropertyReq));
|
||||
return RRConfigureOutputProperty (output, stuff->property,
|
||||
stuff->pending, stuff->range,
|
||||
FALSE, num_valid,
|
||||
|
@ -544,7 +544,7 @@ ProcRRChangeOutputProperty (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;
|
||||
|
@ -708,7 +708,7 @@ ProcRRGetOutputProperty (ClientPtr client)
|
|||
}
|
||||
reply.bytesAfter = n - (ind + len);
|
||||
reply.format = prop_value->format;
|
||||
reply.length = (len + 3) >> 2;
|
||||
reply.length = bytes_to_int32(len);
|
||||
if (prop_value->format)
|
||||
reply.nItems = len / (prop_value->format / 8);
|
||||
else
|
||||
|
|
|
@ -381,8 +381,8 @@ rrGetScreenResources(ClientPtr client, Bool query)
|
|||
|
||||
rep.length = (pScrPriv->numCrtcs +
|
||||
pScrPriv->numOutputs +
|
||||
num_modes * (SIZEOF(xRRModeInfo) >> 2) +
|
||||
((rep.nbytesNames + 3) >> 2));
|
||||
num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
|
||||
bytes_to_int32(rep.nbytesNames));
|
||||
|
||||
extraLen = rep.length << 2;
|
||||
if (extraLen)
|
||||
|
@ -455,7 +455,7 @@ rrGetScreenResources(ClientPtr client, Bool query)
|
|||
names += mode->mode.nameLength;
|
||||
}
|
||||
xfree (modes);
|
||||
assert (((((char *) names - (char *) extra) + 3) >> 2) == rep.length);
|
||||
assert (bytes_to_int32((char *) names - (char *) extra) == rep.length);
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
|
@ -726,7 +726,7 @@ ProcRRGetScreenInfo (ClientPtr client)
|
|||
if (data8 - (CARD8 *) extra != extraLen)
|
||||
FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
|
||||
(unsigned long)(data8 - (CARD8 *) extra), extraLen);
|
||||
rep.length = (extraLen + 3) >> 2;
|
||||
rep.length = bytes_to_int32(extraLen);
|
||||
}
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
|
|
|
@ -375,10 +375,10 @@ SProcRRSetCrtcTransform (ClientPtr client)
|
|||
REQUEST_AT_LEAST_SIZE(xRRSetCrtcTransformReq);
|
||||
swaps(&stuff->length, n);
|
||||
swapl(&stuff->crtc, n);
|
||||
SwapLongs((CARD32 *)&stuff->transform, (sizeof(xRenderTransform)) >> 2);
|
||||
SwapLongs((CARD32 *)&stuff->transform, bytes_to_int32(sizeof(xRenderTransform)));
|
||||
swaps(&stuff->nbytesFilter, n);
|
||||
filter = (char *)(stuff + 1);
|
||||
params = (CARD32 *) (filter + ((stuff->nbytesFilter + 3) & ~3));
|
||||
params = (CARD32 *) (filter + pad_to_int32(stuff->nbytesFilter));
|
||||
nparams = ((CARD32 *) stuff + client->req_len) - params;
|
||||
if (nparams < 0)
|
||||
return BadLength;
|
||||
|
|
|
@ -313,7 +313,7 @@ ProcRRXineramaQueryScreens(ClientPtr client)
|
|||
rep.type = X_Reply;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.number = RRXineramaScreenCount (pScreen);
|
||||
rep.length = rep.number * sz_XineramaScreenInfo >> 2;
|
||||
rep.length = bytes_to_int32(rep.number * sz_XineramaScreenInfo);
|
||||
if(client->swapped) {
|
||||
register int n;
|
||||
swaps(&rep.sequenceNumber, n);
|
||||
|
|
Loading…
Reference in New Issue