Skip to content

Commit 3e99e69

Browse files
committed
[PR #1051] treewide: fix result type of BitmapBytePad() to unsigned
PR: #1051
1 parent 19921fd commit 3e99e69

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
@@ -1993,7 +1993,6 @@ PanoramiXGetImage(ClientPtr client)
19931993
int x, y, w, h, format, rc;
19941994
Mask plane = 0, planemask;
19951995
int linesDone, nlines, linesPerBuf;
1996-
long widthBytesLine;
19971996

19981997
REQUEST(xGetImageReq);
19991998

@@ -2065,6 +2064,8 @@ PanoramiXGetImage(ClientPtr client)
20652064
});
20662065

20672066
size_t length;
2067+
size_t widthBytesLine;
2068+
20682069
if (format == ZPixmap) {
20692070
widthBytesLine = PixmapBytePad(w, pDraw->depth);
20702071
length = widthBytesLine * h;

dix/cursor.c

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

161161
bits->emptyMask = FALSE;
162162
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
@@ -2111,14 +2111,15 @@ ProcPutImage(ClientPtr client)
21112111
{
21122112
GCPtr pGC;
21132113
DrawablePtr pDraw;
2114-
long length; /* length of scanline server padded */
2115-
long lengthProto; /* length of scanline protocol padded */
21162114
char *tmpImage;
21172115

21182116
REQUEST(xPutImageReq);
21192117

21202118
REQUEST_AT_LEAST_SIZE(xPutImageReq);
21212119
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
2120+
2121+
unsigned length; /* length of scanline server padded */
2122+
21222123
if (stuff->format == XYBitmap) {
21232124
if ((stuff->depth != 1) ||
21242125
(stuff->leftPad >= (unsigned int) screenInfo.bitmapScanlinePad))
@@ -2143,7 +2144,7 @@ ProcPutImage(ClientPtr client)
21432144
}
21442145

21452146
tmpImage = (char *) &stuff[1];
2146-
lengthProto = length;
2147+
size_t lengthProto = length; /* length of scanline protocol padded */
21472148

21482149
if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
21492150
return BadLength;
@@ -2174,7 +2175,6 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
21742175

21752176
/* coordinates relative to the bounding drawable */
21762177
int relx, rely;
2177-
long widthBytesLine, length;
21782178
Mask plane = 0;
21792179
RegionPtr pVisibleRegion = NULL;
21802180

@@ -2244,6 +2244,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
22442244
return BadMatch;
22452245

22462246
rep.depth = pDraw->depth;
2247+
2248+
size_t widthBytesLine, length;
22472249
if (format == ZPixmap) {
22482250
widthBytesLine = PixmapBytePad(width, pDraw->depth);
22492251
length = widthBytesLine * height;
@@ -3032,7 +3034,6 @@ ProcCreateCursor(ClientPtr client)
30323034
PixmapPtr msk;
30333035
unsigned char *srcbits;
30343036
unsigned short width, height;
3035-
long n;
30363037
CursorMetricRec cm;
30373038
int rc;
30383039

@@ -3077,7 +3078,8 @@ ProcCreateCursor(ClientPtr client)
30773078
srcbits = calloc(BitmapBytePad(width), height);
30783079
if (!srcbits)
30793080
return BadAlloc;
3080-
n = BitmapBytePad(width) * height;
3081+
3082+
size_t n = BitmapBytePad(width) * height;
30813083

30823084
unsigned char *mskbits = calloc(1, n);
30833085
if (!mskbits) {

dix/window.c

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

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

529+
unsigned len = BitmapBytePad(sizeof(long));
530530
for (int i = 4; i > 0; i--, from++)
531531
for (int j = len; j > 0; j--)
532532
*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)