dmx: switch to byte counting functions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-07-06 12:06:47 +10:00
parent dc82e11e50
commit 87ce93c997
2 changed files with 11 additions and 11 deletions

View File

@ -360,10 +360,10 @@ static int ProcDMXGetScreenAttributes(ClientPtr client)
rep.rootWindowYorigin = attr.rootWindowYorigin; rep.rootWindowYorigin = attr.rootWindowYorigin;
length = attr.displayName ? strlen(attr.displayName) : 0; length = attr.displayName ? strlen(attr.displayName) : 0;
paddedLength = (length + 3) & ~3; paddedLength = pad_to_int32(length);
rep.type = X_Reply; rep.type = X_Reply;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.length = paddedLength >> 2; rep.length = bytes_to_int32(paddedLength);
rep.displayNameLength = length; rep.displayNameLength = length;
if (client->swapped) { if (client->swapped) {
@ -405,7 +405,7 @@ static int ProcDMXChangeScreensAttributes(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xDMXChangeScreensAttributesReq); REQUEST_AT_LEAST_SIZE(xDMXChangeScreensAttributesReq);
len = client->req_len - (sizeof(xDMXChangeScreensAttributesReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xDMXChangeScreensAttributesReq));
if (len < stuff->screenCount + stuff->maskCount) if (len < stuff->screenCount + stuff->maskCount)
return BadLength; return BadLength;
@ -474,8 +474,8 @@ static int ProcDMXAddScreen(ClientPtr client)
int paddedLength; int paddedLength;
REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq); REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq);
paddedLength = (stuff->displayNameLength + 3) & ~3; paddedLength = pad_to_int32(stuff->displayNameLength);
len = client->req_len - (sizeof(xDMXAddScreenReq) >> 2); len = client->req_len - bytes_to_int32(sizeof(xDMXAddScreenReq));
if (len != Ones(stuff->valueMask) + paddedLength/4) if (len != Ones(stuff->valueMask) + paddedLength/4)
return BadLength; return BadLength;
@ -795,10 +795,10 @@ static int ProcDMXGetInputAttributes(ClientPtr client)
rep.detached = attr.detached; rep.detached = attr.detached;
length = attr.name ? strlen(attr.name) : 0; length = attr.name ? strlen(attr.name) : 0;
paddedLength = (length + 3) & ~3; paddedLength = pad_to_int32(length);
rep.type = X_Reply; rep.type = X_Reply;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.length = paddedLength >> 2; rep.length = bytes_to_int32(paddedLength);
rep.nameLength = length; rep.nameLength = length;
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber, n); swaps(&rep.sequenceNumber, n);
@ -828,7 +828,7 @@ static int ProcDMXAddInput(ClientPtr client)
int id = -1; int id = -1;
REQUEST_AT_LEAST_SIZE(xDMXAddInputReq); REQUEST_AT_LEAST_SIZE(xDMXAddInputReq);
paddedLength = (stuff->displayNameLength + 3) & ~3; paddedLength = pad_to_int32(stuff->displayNameLength);
len = client->req_len - (sizeof(xDMXAddInputReq) >> 2); len = client->req_len - (sizeof(xDMXAddInputReq) >> 2);
if (len != Ones(stuff->valueMask) + paddedLength/4) if (len != Ones(stuff->valueMask) + paddedLength/4)
return BadLength; return BadLength;
@ -997,7 +997,7 @@ static int SProcDMXAddScreen(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq); REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq);
swapl(&stuff->displayNameLength, n); swapl(&stuff->displayNameLength, n);
swapl(&stuff->valueMask, n); swapl(&stuff->valueMask, n);
paddedLength = (stuff->displayNameLength + 3) & ~3; paddedLength = pad_to_int32(stuff->displayNameLength);
SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4); SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4);
return ProcDMXAddScreen(client); return ProcDMXAddScreen(client);
} }
@ -1077,7 +1077,7 @@ static int SProcDMXAddInput(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xDMXAddInputReq); REQUEST_AT_LEAST_SIZE(xDMXAddInputReq);
swapl(&stuff->displayNameLength, n); swapl(&stuff->displayNameLength, n);
swapl(&stuff->valueMask, n); swapl(&stuff->valueMask, n);
paddedLength = (stuff->displayNameLength + 3) & ~3; paddedLength = pad_to_int32(stuff->displayNameLength);
SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4); SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4);
return ProcDMXAddInput(client); return ProcDMXAddInput(client);
} }

View File

@ -902,7 +902,7 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
else { else {
/* this is a GL_BITMAP pixel type, should copy bits */ /* this is a GL_BITMAP pixel type, should copy bits */
int r; int r;
int src_rowsize = ((sw * ebits) + 7) / 8; int src_rowsize = bits_to_bytes(sw * ebits);
int src_pad = src_rowsize % 4; int src_pad = src_rowsize % 4;
if ( src_pad ) { if ( src_pad ) {
src_rowsize += (4 - src_pad); src_rowsize += (4 - src_pad);