Skip to content

Commit 2dc290e

Browse files
committed
[PR #1051] treewide: fix result type of BitmapBytePad() to unsigned
PR: #1051
1 parent 85cf8f0 commit 2dc290e

File tree

14 files changed

+31
-33
lines changed

14 files changed

+31
-33
lines changed

Xext/panoramiXprocs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,6 @@ PanoramiXGetImage(ClientPtr client)
19911991
int x, y, w, h, format, rc;
19921992
Mask plane = 0, planemask;
19931993
int linesDone, nlines, linesPerBuf;
1994-
long widthBytesLine;
19951994

19961995
REQUEST(xGetImageReq);
19971996

@@ -2063,6 +2062,8 @@ PanoramiXGetImage(ClientPtr client)
20632062
});
20642063

20652064
size_t length;
2065+
size_t widthBytesLine;
2066+
20662067
if (format == ZPixmap) {
20672068
widthBytesLine = PixmapBytePad(w, pDraw->depth);
20682069
length = widthBytesLine * h;

dix/cursor.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static void
155155
CheckForEmptyMask(CursorBitsPtr bits)
156156
{
157157
unsigned char *msk = bits->mask;
158-
int n = BitmapBytePad(bits->width) * bits->height;
158+
unsigned n = BitmapBytePad(bits->width) * bits->height;
159159

160160
bits->emptyMask = FALSE;
161161
while (n--)
@@ -366,10 +366,9 @@ AllocGlyphCursor(Font source, unsigned short sourceChar, Font mask, unsigned sho
366366
return BadValue;
367367
}
368368
if (!maskfont) {
369-
long n;
370369
unsigned char *mskptr;
371370

372-
n = BitmapBytePad(cm.width) * (long) cm.height;
371+
unsigned n = BitmapBytePad(cm.width) * (long) cm.height;
373372
mskptr = mskbits = calloc(1, n);
374373
if (!mskptr)
375374
return BadAlloc;

dix/dispatch.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,14 +2040,15 @@ ProcPutImage(ClientPtr client)
20402040
{
20412041
GCPtr pGC;
20422042
DrawablePtr pDraw;
2043-
long length; /* length of scanline server padded */
2044-
long lengthProto; /* length of scanline protocol padded */
20452043
char *tmpImage;
20462044

20472045
REQUEST(xPutImageReq);
20482046

20492047
REQUEST_AT_LEAST_SIZE(xPutImageReq);
20502048
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
2049+
2050+
unsigned length; /* length of scanline server padded */
2051+
20512052
if (stuff->format == XYBitmap) {
20522053
if ((stuff->depth != 1) ||
20532054
(stuff->leftPad >= (unsigned int) screenInfo.bitmapScanlinePad))
@@ -2072,7 +2073,7 @@ ProcPutImage(ClientPtr client)
20722073
}
20732074

20742075
tmpImage = (char *) &stuff[1];
2075-
lengthProto = length;
2076+
size_t lengthProto = length; /* length of scanline protocol padded */
20762077

20772078
if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
20782079
return BadLength;
@@ -2103,7 +2104,6 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
21032104

21042105
/* coordinates relative to the bounding drawable */
21052106
int relx, rely;
2106-
long widthBytesLine, length;
21072107
Mask plane = 0;
21082108
RegionPtr pVisibleRegion = NULL;
21092109

@@ -2173,6 +2173,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
21732173
return BadMatch;
21742174

21752175
rep.depth = pDraw->depth;
2176+
2177+
size_t widthBytesLine, length;
21762178
if (format == ZPixmap) {
21772179
widthBytesLine = PixmapBytePad(width, pDraw->depth);
21782180
length = widthBytesLine * height;
@@ -2972,7 +2974,6 @@ ProcCreateCursor(ClientPtr client)
29722974
PixmapPtr msk;
29732975
unsigned char *srcbits;
29742976
unsigned short width, height;
2975-
long n;
29762977
CursorMetricRec cm;
29772978
int rc;
29782979

@@ -3017,7 +3018,8 @@ ProcCreateCursor(ClientPtr client)
30173018
srcbits = calloc(BitmapBytePad(width), height);
30183019
if (!srcbits)
30193020
return BadAlloc;
3020-
n = BitmapBytePad(width) * height;
3021+
3022+
size_t n = BitmapBytePad(width) * height;
30213023

30223024
unsigned char *mskbits = calloc(1, n);
30233025
if (!mskbits) {

dix/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ MakeRootTile(WindowPtr pWin)
500500
ScreenPtr pScreen = pWin->drawable.pScreen;
501501
GCPtr pGC;
502502
unsigned char back[128];
503-
int len = BitmapBytePad(sizeof(long));
504503
unsigned char *from, *to;
505504

506505
pWin->background.pixmap = (*pScreen->CreatePixmap) (pScreen, 4, 4,
@@ -526,6 +525,7 @@ MakeRootTile(WindowPtr pWin)
526525
from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
527526
to = back;
528527

528+
unsigned len = BitmapBytePad(sizeof(long));
529529
for (int i = 4; i > 0; i--, from++)
530530
for (int j = len; j > 0; j--)
531531
*to++ = *from;

fb/fbimage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fbPutImage(DrawablePtr pDrawable,
3434
{
3535
FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
3636
unsigned long i;
37-
FbStride srcStride;
37+
unsigned srcStride;
3838
FbStip *src = (FbStip *) pImage;
3939

4040
x += pDrawable->x;
@@ -211,7 +211,7 @@ fbGetImage(DrawablePtr pDrawable,
211211
int srcBpp;
212212
int srcXoff, srcYoff;
213213
FbStip *dst;
214-
FbStride dstStride;
214+
unsigned dstStride;
215215

216216
/*
217217
* XFree86 DDX empties the root borderClip when the VT is

hw/xnest/Cursor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ xnestRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
6262
Pixmap const mask = xcb_generate_id(xnestUpstreamInfo.conn);
6363
xcb_create_pixmap(xnestUpstreamInfo.conn, 1, mask, winId, pCursor->bits->width, pCursor->bits->height);
6464

65-
int const pixmap_len = BitmapBytePad(pCursor->bits->width) * pCursor->bits->height;
65+
unsigned const pixmap_len = BitmapBytePad(pCursor->bits->width) * pCursor->bits->height;
6666

6767
xcb_put_image(xnestUpstreamInfo.conn,
6868
XCB_IMAGE_FORMAT_XY_BITMAP,

hw/xnest/GCOps.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
106106
y,
107107
leftPad,
108108
depth,
109-
(format == XCB_IMAGE_FORMAT_Z_PIXMAP ? PixmapBytePad(w, depth)
110-
: BitmapBytePad(w + leftPad)) * h,
109+
(format == XCB_IMAGE_FORMAT_Z_PIXMAP ? (unsigned)PixmapBytePad(w, depth)
110+
: BitmapBytePad((unsigned)(w + leftPad))) * (unsigned)h,
111111
(uint8_t*)pImage);
112112
}
113113

hw/xnest/Pixmap.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ RegionPtr
9494
xnestPixmapToRegion(PixmapPtr pPixmap)
9595
{
9696
register RegionPtr pReg, pTmpReg;
97-
register int x, y;
9897
unsigned long previousPixel, currentPixel;
9998
BoxRec Box = { 0, 0, 0, 0 };
10099
Bool overlap;
@@ -139,13 +138,13 @@ xnestPixmapToRegion(PixmapPtr pPixmap)
139138
}
140139

141140
uint8_t *image_data = xcb_get_image_data(reply);
142-
for (y = 0; y < pPixmap->drawable.height; y++) {
141+
for (unsigned y = 0; y < pPixmap->drawable.height; y++) {
143142
Box.y1 = y;
144143
Box.y2 = y + 1;
145144
previousPixel = 0L;
146-
const int line_start = BitmapBytePad(pPixmap->drawable.width) * y;
145+
const unsigned line_start = BitmapBytePad(pPixmap->drawable.width) * y;
147146

148-
for (x = 0; x < pPixmap->drawable.width; x++) {
147+
for (unsigned x = 0; x < pPixmap->drawable.width; x++) {
149148
currentPixel = ((image_data[line_start + (x/8)]) >> (x % 8)) & 1;
150149
if (previousPixel != currentPixel) {
151150
if (previousPixel == 0L) {

hw/xnest/xcb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ uint32_t xnest_create_bitmap_from_data(
108108
0 /* dst_y */,
109109
leftPad,
110110
1 /* depth */,
111-
BitmapBytePad(width + leftPad) * height,
111+
BitmapBytePad((unsigned)(width + leftPad)) * (unsigned)height,
112112
(uint8_t*)data);
113113

114114
xcb_free_gc(conn, gc);
@@ -149,7 +149,7 @@ uint32_t xnest_create_pixmap_from_bitmap_data(
149149
0 /* dst_y */,
150150
leftPad,
151151
1 /* depth */,
152-
BitmapBytePad(width + leftPad) * height,
152+
BitmapBytePad((unsigned)(width + leftPad)) * (unsigned)height,
153153
(uint8_t*)data);
154154

155155
xcb_free_gc(conn, gc);

hw/xwin/wincursor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
207207
for (y = 0; y < nCY; ++y)
208208
for (x = 0; x < xmax; ++x) {
209209
int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
210-
int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
210+
unsigned nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
211211

212212
pAnd[nWinPix] = 0;
213213
if (fReverse)
@@ -222,7 +222,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
222222
for (y = 0; y < nCY; ++y)
223223
for (x = 0; x < xmax; ++x) {
224224
int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
225-
int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
225+
unsigned nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
226226

227227
unsigned char mask = pCursor->bits->mask[nXPix];
228228

@@ -318,7 +318,7 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
318318
bit = pAnd[nWinPix];
319319
bit = bit & (1 << (7 - (x & 7)));
320320
if (!bit) { /* Within the cursor mask? */
321-
int nXPix =
321+
unsigned nXPix =
322322
BitmapBytePad(pCursor->bits->width) * y +
323323
(x / 8);
324324
bit =

0 commit comments

Comments
 (0)