diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index f83bcd5e3..25aa4f51d 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1178,7 +1178,7 @@ DGAGetOldDGAMode(int index) w = pScrn->currentMode->HDisplay; h = pScrn->currentMode->VDisplay; - p = ((pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) + 3) & ~3L; + p = pad_to_int32(pScrn->displayWidth * bits_to_bytes(pScrn->bitsPerPixel)); for(i = 0; i < pScreenPriv->numModes; i++) { mode = &(pScreenPriv->modes[i]); diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c index 46aa8b882..6286659fa 100644 --- a/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -159,7 +159,7 @@ ProcXDGAOpenFramebuffer(ClientPtr client) } nameSize = deviceName ? (strlen(deviceName) + 1) : 0; - rep.length = (nameSize + 3) >> 2; + rep.length = bytes_to_int32(nameSize); WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep); if(rep.length) @@ -225,10 +225,10 @@ ProcXDGAQueryModes(ClientPtr client) size = num * sz_xXDGAModeInfo; for(i = 0; i < num; i++) - size += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */ + size += pad_to_int32(strlen(mode[i].name) + 1); /* plus NULL */ rep.number = num; - rep.length = size >> 2; + rep.length = bytes_to_int32(size); WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); @@ -389,7 +389,7 @@ ProcXDGASetMode(ClientPtr client) info.reserved1 = mode.reserved1; info.reserved2 = mode.reserved2; - rep.length = (sz_xXDGAModeInfo + info.name_size) >> 2; + rep.length = bytes_to_int32(sz_xXDGAModeInfo + info.name_size); WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index bd6c59462..2e82f331a 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -414,11 +414,11 @@ ProcXF86VidModeGetModeLine(ClientPtr client) REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); rep.type = X_Reply; if (ver < 2) { - rep.length = (SIZEOF(xXF86OldVidModeGetModeLineReply) - - SIZEOF(xGenericReply)) >> 2; + rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) - + SIZEOF(xGenericReply)); } else { - rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) - - SIZEOF(xGenericReply)) >> 2; + rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) - + SIZEOF(xGenericReply)); } rep.sequenceNumber = client->sequence; @@ -670,10 +670,10 @@ ProcXF86VidModeAddModeLine(ClientPtr client) if (ver < 2) { REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq); - len = client->req_len - (sizeof(xXF86OldVidModeAddModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq)); } else { REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); - len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq)); } if (len != stuff->privsize) return BadLength; @@ -809,10 +809,10 @@ ProcXF86VidModeDeleteModeLine(ClientPtr client) if (ver < 2) { REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq); - len = client->req_len - (sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq)); } else { REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); - len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq)); } if (len != stuff->privsize) { if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) { @@ -923,10 +923,10 @@ ProcXF86VidModeModModeLine(ClientPtr client) if (ver < 2) { REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq); - len = client->req_len - (sizeof(xXF86OldVidModeModModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq)); } else { REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); - len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeModModeLineReq)); } if (len != stuff->privsize) return BadLength; @@ -1052,10 +1052,10 @@ ProcXF86VidModeValidateModeLine(ClientPtr client) if (ver < 2) { REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq); len = client->req_len - - (sizeof(xXF86OldVidModeValidateModeLineReq) >> 2); + bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq)); } else { REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); - len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq)); } if (len != stuff->privsize) return BadLength; @@ -1107,8 +1107,8 @@ status_reply: xfree(modetmp); rep.type = X_Reply; - rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply) - - SIZEOF(xGenericReply)) >> 2; + rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply) + - SIZEOF(xGenericReply)); rep.sequenceNumber = client->sequence; rep.status = status; if (client->swapped) { @@ -1185,10 +1185,10 @@ ProcXF86VidModeSwitchToMode(ClientPtr client) if (ver < 2) { REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq); - len = client->req_len - (sizeof(xXF86OldVidModeSwitchToModeReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq)); } else { REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq); - len = client->req_len - (sizeof(xXF86VidModeSwitchToModeReq) >> 2); + len = client->req_len - bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq)); } if (len != stuff->privsize) return BadLength; @@ -1289,10 +1289,10 @@ ProcXF86VidModeGetMonitor(ClientPtr client) VIDMODE_MON_MODEL, 0)).ptr); else rep.modelLength = 0; - rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) + + rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) + (nHsync + nVrefresh) * sizeof(CARD32) + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)) >> 2; + pad_to_int32(rep.vendorLength) + + pad_to_int32(rep.modelLength)); rep.sequenceNumber = client->sequence; rep.nhsync = nHsync; rep.nvsync = nVrefresh; @@ -1413,8 +1413,8 @@ ProcXF86VidModeGetDotClocks(ClientPtr client) numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg); rep.type = X_Reply; - rep.length = (SIZEOF(xXF86VidModeGetDotClocksReply) - - SIZEOF(xGenericReply) + numClocks) >> 2; + rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply) + - SIZEOF(xGenericReply) + numClocks); rep.sequenceNumber = client->sequence; rep.clocks = numClocks; rep.maxclocks = MAXCLOCKS; diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 902fe1264..d3e5e688a 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -214,8 +214,8 @@ ProcXF86DRIOpenConnection( rep.busIdStringLength = 0; if (busIdString) rep.busIdStringLength = strlen(busIdString); - rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) + - ((rep.busIdStringLength + 3) & ~3)) >> 2; + rep.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) + + pad_to_int32(rep.busIdStringLength)); rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff); #if defined(LONG64) && !defined(__linux__) @@ -300,9 +300,9 @@ ProcXF86DRIGetClientDriverName( rep.clientDriverNameLength = 0; if (clientDriverName) rep.clientDriverNameLength = strlen(clientDriverName); - rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) - + rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) - SIZEOF(xGenericReply) + - ((rep.clientDriverNameLength + 3) & ~3)) >> 2; + pad_to_int32(rep.clientDriverNameLength)); WriteToClient(client, sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep); @@ -515,7 +515,7 @@ ProcXF86DRIGetDrawableInfo( rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; } - rep.length = ((rep.length + 3) & ~3) >> 2; + rep.length = bytes_to_int32(rep.length); WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep); @@ -574,9 +574,9 @@ ProcXF86DRIGetDeviceInfo( rep.length = 0; if (rep.devPrivateSize) { - rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) - + rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) - SIZEOF(xGenericReply) + - ((rep.devPrivateSize + 3) & ~3)) >> 2; + pad_to_int32(rep.devPrivateSize)); } WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep); diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 74d8648ec..0449af202 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -123,7 +123,7 @@ unsigned int xf86ModeBandwidth(DisplayModePtr mode, int depth) { float a_active, a_total, active_percent, pixels_per_second; - int bytes_per_pixel = (depth + 7) / 8; + int bytes_per_pixel = bits_to_bytes(depth); if (!mode->HTotal || !mode->VTotal || !mode->Clock) return 0; diff --git a/hw/xfree86/os-support/linux/lnx_font.c b/hw/xfree86/os-support/linux/lnx_font.c index 5b2696af5..d6fc283c0 100644 --- a/hw/xfree86/os-support/linux/lnx_font.c +++ b/hw/xfree86/os-support/linux/lnx_font.c @@ -168,7 +168,7 @@ lnx_savefont(void) return FALSE; } - size = (width + 7)/8 * 32 * charcount; + size = bits_to_bytes(width) * 32 * charcount; fontdata = (unsigned char *)xnfalloc(size); if (!fontdata) { xf86Msg(X_WARNING, diff --git a/hw/xfree86/xaa/xaaFillRect.c b/hw/xfree86/xaa/xaaFillRect.c index 7c319bba8..0b83ef3ee 100644 --- a/hw/xfree86/xaa/xaaFillRect.c +++ b/hw/xfree86/xaa/xaaFillRect.c @@ -812,7 +812,7 @@ WriteColumn( src = pSrc + (yoff * srcwidth); - dwords = ((w * Bpp) + 3) >> 2; + dwords = bytes_to_int32(w * Bpp); if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01)) { diff --git a/hw/xfree86/xaa/xaaImage.c b/hw/xfree86/xaa/xaaImage.c index 85461c8ad..4933beea3 100644 --- a/hw/xfree86/xaa/xaaImage.c +++ b/hw/xfree86/xaa/xaaImage.c @@ -92,7 +92,7 @@ XAAWritePixmap32To24( int trans ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int count, dwords = ((w * 3) + 3) >> 2; + int count, dwords = bytes_to_int32(w * 3); CARD32 *src, *dst; Bool PlusOne = FALSE; @@ -227,7 +227,7 @@ XAAWritePixmap ( BAD_ALIGNMENT: - dwords = ((w * Bpp) + 3) >> 2; + dwords = bytes_to_int32(w * Bpp); if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01)) { @@ -351,7 +351,7 @@ XAAWritePixmapScanline ( BAD_ALIGNMENT: - dwords = ((w * Bpp) + 3) >> 2; + dwords = bytes_to_int32(w * Bpp); (*infoRec->SetupForScanlineImageWrite)( pScrn, rop, planemask, trans, bpp, depth); diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c index dbbeac668..7e3011bd5 100644 --- a/hw/xfree86/xaa/xaaPCache.c +++ b/hw/xfree86/xaa/xaaPCache.c @@ -1556,7 +1556,7 @@ XAACacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix) } else funcNo = 2; pad = BitmapBytePad(pCache->w * bpp); - dwords = pad >> 2; + dwords = bytes_to_int32(pad); dstPtr = data = (unsigned char*)xalloc(pad * pCache->h); srcPtr = (unsigned char*)pPix->devPrivate.ptr;