[PATCH 05/18] dmx: switch to byte counting functions

Peter Hutterer peter.hutterer at who-t.net
Wed Jul 8 17:05:03 PDT 2009


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/dmx/dmx.c                |   20 ++++++++++----------
 hw/dmx/glxProxy/glxsingle.c |    2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c
index 56e5bb6..5db20b9 100644
--- a/hw/dmx/dmx.c
+++ b/hw/dmx/dmx.c
@@ -360,10 +360,10 @@ static int ProcDMXGetScreenAttributes(ClientPtr client)
     rep.rootWindowYorigin   = attr.rootWindowYorigin;
                                  
     length                  = attr.displayName ? strlen(attr.displayName) : 0;
-    paddedLength            = (length + 3) & ~3;
+    paddedLength            = pad_to_dwords(length);
     rep.type                = X_Reply;
     rep.sequenceNumber      = client->sequence;
-    rep.length              = paddedLength >> 2;
+    rep.length              = num_dwords_for_bytes(paddedLength);
     rep.displayNameLength   = length;
 
     if (client->swapped) {
@@ -405,7 +405,7 @@ static int ProcDMXChangeScreensAttributes(ClientPtr client)
     
 
     REQUEST_AT_LEAST_SIZE(xDMXChangeScreensAttributesReq);
-    len = client->req_len - (sizeof(xDMXChangeScreensAttributesReq) >> 2);
+    len = client->req_len - num_dwords_for_bytes(sizeof(xDMXChangeScreensAttributesReq));
     if (len < stuff->screenCount + stuff->maskCount)
         return BadLength;
 
@@ -474,8 +474,8 @@ static int ProcDMXAddScreen(ClientPtr client)
     int                    paddedLength;
 
     REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq);
-    paddedLength = (stuff->displayNameLength + 3) & ~3;
-    len          = client->req_len - (sizeof(xDMXAddScreenReq) >> 2);
+    paddedLength = pad_to_dwords(stuff->displayNameLength);
+    len          = client->req_len - num_dwords_for_bytes(sizeof(xDMXAddScreenReq));
     if (len != Ones(stuff->valueMask) + paddedLength/4)
         return BadLength;
 
@@ -795,10 +795,10 @@ static int ProcDMXGetInputAttributes(ClientPtr client)
     rep.detached       = attr.detached;
     
     length             = attr.name ? strlen(attr.name) : 0;
-    paddedLength       = (length + 3) & ~3;
+    paddedLength       = pad_to_dwords(length);
     rep.type           = X_Reply;
     rep.sequenceNumber = client->sequence;
-    rep.length         = paddedLength >> 2;
+    rep.length         = num_dwords_for_bytes(paddedLength);
     rep.nameLength     = length;
     if (client->swapped) {
     	swaps(&rep.sequenceNumber, n);
@@ -828,7 +828,7 @@ static int ProcDMXAddInput(ClientPtr client)
     int                    id     = -1;
 
     REQUEST_AT_LEAST_SIZE(xDMXAddInputReq);
-    paddedLength = (stuff->displayNameLength + 3) & ~3;
+    paddedLength = pad_to_dwords(stuff->displayNameLength);
     len          = client->req_len - (sizeof(xDMXAddInputReq) >> 2);
     if (len != Ones(stuff->valueMask) + paddedLength/4)
         return BadLength;
@@ -997,7 +997,7 @@ static int SProcDMXAddScreen(ClientPtr client)
     REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq);
     swapl(&stuff->displayNameLength, n);
     swapl(&stuff->valueMask, n);
-    paddedLength = (stuff->displayNameLength + 3) & ~3;
+    paddedLength = pad_to_dwords(stuff->displayNameLength);
     SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4);
     return ProcDMXAddScreen(client);
 }
@@ -1077,7 +1077,7 @@ static int SProcDMXAddInput(ClientPtr client)
     REQUEST_AT_LEAST_SIZE(xDMXAddInputReq);
     swapl(&stuff->displayNameLength, n);
     swapl(&stuff->valueMask, n);
-    paddedLength = (stuff->displayNameLength + 3) & ~3;
+    paddedLength = pad_to_dwords(stuff->displayNameLength);
     SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4);
     return ProcDMXAddInput(client);
 }
diff --git a/hw/dmx/glxProxy/glxsingle.c b/hw/dmx/glxProxy/glxsingle.c
index 4d2d45b..f0c3bbb 100644
--- a/hw/dmx/glxProxy/glxsingle.c
+++ b/hw/dmx/glxProxy/glxsingle.c
@@ -902,7 +902,7 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
 		   else {
 		      /* this is a GL_BITMAP pixel type, should copy bits */
 		      int r;
-		      int src_rowsize = ((sw * ebits) + 7) / 8;
+		      int src_rowsize = num_bytes_for_bits(sw * ebits);
 		      int src_pad = src_rowsize % 4;
                       if ( src_pad ) {
 			 src_rowsize += (4 - src_pad);
-- 
1.6.3.rc1.2.g0164.dirty



More information about the xorg-devel mailing list