diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-05-07 12:28:48 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-05-07 12:37:22 -0700 |
commit | ee2b4beba48dadab804d1b6f79fbaaeaf26ed904 (patch) | |
tree | 41628dc787aab82a6518ef032276a7969d90cc06 /src | |
parent | 3c32eedb0c6e300c9701da42c6300a8ef7bde7fd (diff) |
Variable scope reductions as suggested by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/alp_hwcurs.c | 6 | ||||
-rw-r--r-- | src/cir_shadow.c | 112 | ||||
-rw-r--r-- | src/lg_hwcurs.c | 3 |
3 files changed, 58 insertions, 63 deletions
diff --git a/src/alp_hwcurs.c b/src/alp_hwcurs.c index afab7a0..c369ffe 100644 --- a/src/alp_hwcurs.c +++ b/src/alp_hwcurs.c @@ -51,7 +51,7 @@ AlpLoadSkewedCursor(CirPtr pCir, int x, int y) { unsigned char mem[2*MAXCURSORSIZE]; unsigned char *p1, *p2; - int i, j, m, a, b; + int i, a, b; Bool cur64 = (CURSORWIDTH == 64); int shift = (cur64? 1 : 0); @@ -96,10 +96,10 @@ AlpLoadSkewedCursor(CirPtr pCir, int x, int y) { and cyrsor bits. */ p2 = mem + CURSORWIDTH/8 - (x>>3) - 1; for (i = 0; i < 2*CURSORHEIGHT; i++) { - m = (-1)<<(x&7); + int m = (-1)<<(x&7); p1 = p2; p2 += CURSORWIDTH/8; - for (j = x>>3; j >= 0; j--) { + for (int j = x>>3; j >= 0; j--) { *p1 &= m; m = 0; p1++; diff --git a/src/cir_shadow.c b/src/cir_shadow.c index 6bde0fd..7345924 100644 --- a/src/cir_shadow.c +++ b/src/cir_shadow.c @@ -22,20 +22,19 @@ _X_EXPORT void cirRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { CirPtr pCir = CIRPTR(pScrn); - int width, height, Bpp, FBPitch, x1, x2, y1, y2; unsigned char *src, *dst; - Bpp = pScrn->bitsPerPixel >> 3; - FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + int Bpp = pScrn->bitsPerPixel >> 3; + int FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); while(num--) { - x1 = MAX(pbox->x1, 0); - y1 = MAX(pbox->y1, 0); - x2 = MIN(pbox->x2, pScrn->virtualX); - y2 = MIN(pbox->y2, pScrn->virtualY); + int x1 = MAX(pbox->x1, 0); + int y1 = MAX(pbox->y1, 0); + int x2 = MIN(pbox->x2, pScrn->virtualX); + int y2 = MIN(pbox->y2, pScrn->virtualY); - width = (x2 - x1) * Bpp; - height = y2 - y1; + int width = (x2 - x1) * Bpp; + int height = y2 - y1; if (width <= 0 || height <= 0) continue; @@ -75,18 +74,17 @@ _X_EXPORT void cirRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { CirPtr pCir = CIRPTR(pScrn); - int count, width, height, x1, x2, y1, y2, dstPitch, srcPitch; - CARD8 *dstPtr, *srcPtr, *src; - CARD32 *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pCir->rotate * pCir->ShadowPitch; + int dstPitch = pScrn->displayWidth; + int srcPitch = -pCir->rotate * pCir->ShadowPitch; while(num--) { - x1 = MAX(pbox->x1, 0); - y1 = MAX(pbox->y1, 0); - x2 = MIN(pbox->x2, pScrn->virtualX); - y2 = MIN(pbox->y2, pScrn->virtualY); + int x1 = MAX(pbox->x1, 0); + int y1 = MAX(pbox->y1, 0); + int x2 = MIN(pbox->x2, pScrn->virtualX); + int y2 = MIN(pbox->y2, pScrn->virtualY); + int width, height; + CARD8 *dstPtr, *srcPtr; width = x2 - x1; y1 = y1 & ~3; @@ -107,9 +105,9 @@ cirRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } while(width--) { - src = srcPtr; - dst = (CARD32*)dstPtr; - count = height; + CARD8 *src = srcPtr; + CARD32 *dst = (CARD32*)dstPtr; + int count = height; while(count--) { *(dst++) = src[0] | (src[srcPitch] << 8) | (src[srcPitch * 2] << 16) | @@ -129,18 +127,17 @@ _X_EXPORT void cirRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { CirPtr pCir = CIRPTR(pScrn); - int count, width, height, x1, x2, y1, y2, dstPitch, srcPitch; - CARD16 *dstPtr, *srcPtr, *src; - CARD32 *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pCir->rotate * pCir->ShadowPitch >> 1; + int dstPitch = pScrn->displayWidth; + int srcPitch = -pCir->rotate * pCir->ShadowPitch >> 1; while(num--) { - x1 = MAX(pbox->x1, 0); - y1 = MAX(pbox->y1, 0); - x2 = MIN(pbox->x2, pScrn->virtualX); - y2 = MIN(pbox->y2, pScrn->virtualY); + int x1 = MAX(pbox->x1, 0); + int y1 = MAX(pbox->y1, 0); + int x2 = MIN(pbox->x2, pScrn->virtualX); + int y2 = MIN(pbox->y2, pScrn->virtualY); + int width, height; + CARD16 *dstPtr, *srcPtr; width = x2 - x1; y1 = y1 & ~1; @@ -163,9 +160,9 @@ cirRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } while(width--) { - src = srcPtr; - dst = (CARD32*)dstPtr; - count = height; + CARD16 *src = srcPtr; + CARD32 *dst = (CARD32*)dstPtr; + int count = height; while(count--) { *(dst++) = src[0] | (src[srcPitch] << 16); src += srcPitch * 2; @@ -184,18 +181,17 @@ _X_EXPORT void cirRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { CirPtr pCir = CIRPTR(pScrn); - int count, width, height, x1, x2, y1, y2, dstPitch, srcPitch; - CARD8 *dstPtr, *srcPtr, *src; - CARD32 *dst; - dstPitch = BitmapBytePad(pScrn->displayWidth * 24); - srcPitch = -pCir->rotate * pCir->ShadowPitch; + int dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + int srcPitch = -pCir->rotate * pCir->ShadowPitch; while(num--) { - x1 = MAX(pbox->x1, 0); - y1 = MAX(pbox->y1, 0); - x2 = MIN(pbox->x2, pScrn->virtualX); - y2 = MIN(pbox->y2, pScrn->virtualY); + int x1 = MAX(pbox->x1, 0); + int y1 = MAX(pbox->y1, 0); + int x2 = MIN(pbox->x2, pScrn->virtualX); + int y2 = MIN(pbox->y2, pScrn->virtualY); + int width, height; + CARD8 *dstPtr, *srcPtr; width = x2 - x1; y1 = y1 & ~3; @@ -216,9 +212,9 @@ cirRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } while(width--) { - src = srcPtr; - dst = (CARD32*)dstPtr; - count = height; + CARD8 *src = srcPtr; + CARD32 *dst = (CARD32*)dstPtr; + int count = height; while(count--) { dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | (src[srcPitch] << 24); @@ -243,20 +239,20 @@ _X_EXPORT void cirRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { CirPtr pCir = CIRPTR(pScrn); - int count, width, height, x1, x2, y1, y2, dstPitch, srcPitch; - CARD32 *dstPtr, *srcPtr, *src, *dst; - dstPitch = pScrn->displayWidth; - srcPitch = -pCir->rotate * pCir->ShadowPitch >> 2; + int dstPitch = pScrn->displayWidth; + int srcPitch = -pCir->rotate * pCir->ShadowPitch >> 2; while(num--) { - x1 = MAX(pbox->x1, 0); - y1 = MAX(pbox->y1, 0); - x2 = MIN(pbox->x2, pScrn->virtualX); - y2 = MIN(pbox->y2, pScrn->virtualY); + int x1 = MAX(pbox->x1, 0); + int y1 = MAX(pbox->y1, 0); + int x2 = MIN(pbox->x2, pScrn->virtualX); + int y2 = MIN(pbox->y2, pScrn->virtualY); - width = x2 - x1; - height = y2 - y1; + int width = x2 - x1; + int height = y2 - y1; + + CARD32 *dstPtr, *srcPtr; if (width <= 0 || height <= 0) continue; @@ -274,9 +270,9 @@ cirRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) } while(width--) { - src = srcPtr; - dst = dstPtr; - count = height; + CARD32 *src = srcPtr; + CARD32 *dst = dstPtr; + int count = height; while(count--) { *(dst++) = *src; src += srcPitch; diff --git a/src/lg_hwcurs.c b/src/lg_hwcurs.c index 20ac38a..51862b2 100644 --- a/src/lg_hwcurs.c +++ b/src/lg_hwcurs.c @@ -230,7 +230,6 @@ LgFindCursorTile(ScrnInfoPtr pScrn, int *x, int *y, int *width, int *height, int tilesPerLine = LgLineData[pLg->lineDataIndex].tilesPerLine; int filledOutTileLines, leftoverMem; int yTile, xTile; - int tileNumber; filledOutTileLines = videoRam / (tilesPerLine * 2); /* tiles are 2K */ leftoverMem = videoRam - filledOutTileLines*tilesPerLine*2; @@ -276,7 +275,7 @@ LgFindCursorTile(ScrnInfoPtr pScrn, int *x, int *y, int *width, int *height, page = page & 0x1FF; *curAddr = bank*1024*1024L + page*2048 + (nY%tileHeight)*tileWidth; } else { - tileNumber = (tilesPerLine*nIL) * (yTile/nIL) + yTile % nIL; + int tileNumber = (tilesPerLine*nIL) * (yTile/nIL) + yTile % nIL; *curAddr = tileNumber * 2048; } } |