[PATCH 11/18] randr: switch to byte counting functions
Peter Hutterer
peter.hutterer at who-t.net
Wed Jul 8 17:05:09 PDT 2009
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
randr/rrcrtc.c | 14 +++++++-------
randr/rrmode.c | 4 ++--
randr/rroutput.c | 8 ++++----
randr/rrproperty.c | 8 ++++----
randr/rrscreen.c | 8 ++++----
randr/rrsdispatch.c | 4 ++--
randr/rrxinerama.c | 2 +-
7 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 32a0992..cc76a0b 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -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 - num_dwords_for_bytes(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 = num_dwords_for_bytes(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 - num_dwords_for_bytes(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_dwords(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_dwords(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, num_dwords_for_bytes(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 = num_dwords_for_bytes(CrtcTransformExtra + nextra);
reply->hasTransforms = crtc->transforms;
diff --git a/randr/rrmode.c b/randr/rrmode.c
index 2a10076..0e66b9b 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -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 - num_dwords_for_bytes(sizeof (xRRCreateModeReq)));
/* check to make sure requested name fits within the data provided */
- if ((int) (modeInfo->nameLength + 3) >> 2 > units_after)
+ if (num_dwords_for_bytes(modeInfo->nameLength) > units_after)
return BadLength;
mode = RRModeCreateUser (pScreen, modeInfo, name, &error);
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 127497e..3ea814c 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -455,7 +455,7 @@ ProcRRGetOutputInfo (ClientPtr client)
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
- rep.length = OutputInfoExtra >> 2;
+ rep.length = num_dwords_for_bytes(OutputInfoExtra);
rep.timestamp = pScrPriv->lastSetTime.milliseconds;
rep.crtc = output->crtc ? output->crtc->id : None;
rep.mmWidth = output->mmWidth;
@@ -468,14 +468,14 @@ ProcRRGetOutputInfo (ClientPtr client)
rep.nClones = output->numClones;
rep.nameLength = output->nameLength;
- extraLen = ((output->numCrtcs +
+ extraLen = ((output->numCrtcs +
output->numModes + output->numUserModes +
output->numClones +
- ((rep.nameLength + 3) >> 2)) << 2);
+ num_dwords_for_bytes(rep.nameLength)) << 2);
if (extraLen)
{
- rep.length += extraLen >> 2;
+ rep.length += num_dwords_for_bytes(extraLen);
extra = xalloc (extraLen);
if (!extra)
return BadAlloc;
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 775d9e2..0190516 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -429,7 +429,7 @@ ProcRRListOutputProperties (ClientPtr client)
return(BadAlloc);
rep.type = X_Reply;
- rep.length = (numProps * sizeof(Atom)) >> 2;
+ rep.length = num_dwords_for_bytes(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 - num_dwords_for_bytes(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 > num_dwords_for_bytes((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 = num_dwords_for_bytes(len);
if (prop_value->format)
reply.nItems = len / (prop_value->format / 8);
else
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index a919ffd..98fb259 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -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 * num_dwords_for_bytes(SIZEOF(xRRModeInfo)) +
+ num_dwords_for_bytes(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 (num_dwords_for_bytes((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 = num_dwords_for_bytes(extraLen);
}
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index f6821c3..88f6057 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -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, num_dwords_for_bytes(sizeof(xRenderTransform)));
swaps(&stuff->nbytesFilter, n);
filter = (char *)(stuff + 1);
- params = (CARD32 *) (filter + ((stuff->nbytesFilter + 3) & ~3));
+ params = (CARD32 *) (filter + pad_to_dwords(stuff->nbytesFilter));
nparams = ((CARD32 *) stuff + client->req_len) - params;
if (nparams < 0)
return BadLength;
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index d81a857..10b5e6f 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -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 = num_dwords_for_bytes(rep.number * sz_XineramaScreenInfo);
if(client->swapped) {
register int n;
swaps(&rep.sequenceNumber, n);
--
1.6.3.rc1.2.g0164.dirty
More information about the xorg-devel
mailing list