diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-05-10 15:14:05 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-05-10 15:14:05 -0700 |
commit | 12bf0ad76003676b550f6101e692fc0324af61a3 (patch) | |
tree | 4c6cac9faea2290c2f7a6a9fec7b792a396f70b5 | |
parent | 63c947f7184ae9a03a7dd53091ab6f3ec53250da (diff) |
Variable scope reductions as suggested by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/i740_cursor.c | 11 | ||||
-rw-r--r-- | src/i740_dga.c | 4 | ||||
-rw-r--r-- | src/i740_driver.c | 42 | ||||
-rw-r--r-- | src/i740_video.c | 9 |
4 files changed, 29 insertions, 37 deletions
diff --git a/src/i740_cursor.c b/src/i740_cursor.c index 7ea16e4..965e71c 100644 --- a/src/i740_cursor.c +++ b/src/i740_cursor.c @@ -132,14 +132,11 @@ I740UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) static void I740LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) { - I740Ptr pI740; - int x, y; - CARD8 *pcurs; + I740Ptr pI740 = I740PTR(pScrn); + CARD8 *pcurs = (CARD8 *) (pI740->FbBase + pI740->CursorStart); - pI740 = I740PTR(pScrn); - pcurs = (CARD8 *) (pI740->FbBase + pI740->CursorStart); - for (y = 0; y < 64; y++) { - for (x = 0; x < 64 / 4; x++) { + for (int y = 0; y < 64; y++) { + for (int x = 0; x < 64 / 4; x++) { *pcurs++ = *src++; } } diff --git a/src/i740_dga.c b/src/i740_dga.c index 7c63384..2ad9188 100644 --- a/src/i740_dga.c +++ b/src/i740_dga.c @@ -79,7 +79,7 @@ I740DGAInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); I740Ptr pI740 = I740PTR(pScrn); - DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DGAModePtr modes = NULL, currentMode; DisplayModePtr pMode, firstMode; int Bpp = pScrn->bitsPerPixel >> 3; int num = 0; @@ -88,7 +88,7 @@ I740DGAInit(ScreenPtr pScreen) while (pMode) { - newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec)); + DGAModePtr newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec)); if (!newmodes) { free(modes); diff --git a/src/i740_driver.c b/src/i740_driver.c index 7df1a0a..0bc81a4 100644 --- a/src/i740_driver.c +++ b/src/i740_driver.c @@ -289,7 +289,7 @@ I740Identify(int flags) static Bool I740Probe(DriverPtr drv, int flags) { - int i, numUsed, numDevSections, *usedChips; + int numUsed, numDevSections, *usedChips; GDevPtr *devSections; Bool foundScreen = FALSE; @@ -321,7 +321,7 @@ I740Probe(DriverPtr drv, int flags) if (flags & PROBE_DETECT) foundScreen = TRUE; else { - for (i = 0; i < numUsed; i++) { + for (int i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn = NULL; /* Allocate new ScrnInfoRec and claim the slot */ @@ -357,7 +357,7 @@ I740Probe(DriverPtr drv, int flags) if (flags & PROBE_DETECT) foundScreen = TRUE; else { - for (i = 0; i < numUsed; i++) { + for (int i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn = NULL; if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], @@ -1512,17 +1512,13 @@ static void I740LoadPalette15(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) { - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; - - hwp = VGAHWPTR(pScrn); + vgaHWPtr hwp = VGAHWPTR(pScrn); - for (i = 0; i < numColors; i++) { - index = indices[i / 2]; - r = colors[index].red; - b = colors[index].blue; - g = colors[index].green; + for (int i = 0; i < numColors; i++) { + int index = indices[i / 2]; + unsigned char r = colors[index].red; + unsigned char b = colors[index].blue; + unsigned char g = colors[index].green; hwp->writeDacWriteAddr(hwp, index << 2); hwp->writeDacData(hwp, r); @@ -1541,12 +1537,12 @@ static void I740LoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) { - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + for (int i = 0; i < numColors; i++) { + int index; + unsigned char r, g, b; - hwp = VGAHWPTR(pScrn); - for (i = 0; i < numColors; i++) { index = indices[i / 2]; r = colors[index].red; b = colors[index].blue; @@ -1570,12 +1566,12 @@ static void I740LoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) { - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; + vgaHWPtr hwp = VGAHWPTR(pScrn); + + for (int i = 0; i < numColors; i++) { + int index; + unsigned char r, g, b; - hwp = VGAHWPTR(pScrn); - for (i = 0; i < numColors; i++) { index = indices[i]; r = colors[index].red; b = colors[index].blue; diff --git a/src/i740_video.c b/src/i740_video.c index e4b3e10..958d4e8 100644 --- a/src/i740_video.c +++ b/src/i740_video.c @@ -522,7 +522,6 @@ I740CopyMungedData(ScrnInfoPtr pScrn, I740Ptr pI740 = I740PTR(pScrn); I740PortPrivPtr pPriv = pI740->adaptor->pPortPrivates[0].ptr; CARD32 *dst; - int i, j; if (pPriv->currentBuf == 0) dst = (CARD32 *) (pI740->FbBase + pPriv->YBuf0offset); @@ -539,7 +538,7 @@ I740CopyMungedData(ScrnInfoPtr pScrn, long halfx = scalex / 2; long dstj = 0; - for (j = 0; j < dsth; j++) { + for (int j = 0; j < dsth; j++) { int dstj_rnd = dstj >> 16; unsigned char *src1_ = src1 + (dstj_rnd * srcPitch); unsigned char *src2_ = src2 + ((dstj_rnd / 2) * srcPitch2); @@ -547,7 +546,7 @@ I740CopyMungedData(ScrnInfoPtr pScrn, int dstw = ((long) w * 0x10000L + halfx - 1) / scalex; long srci = 0; - for (i = 0; i < dstw; i++) { + for (int i = 0; i < dstw; i++) { long srci_rnd = srci >> 16; long srci2_rnd = (srci + halfx) >> 16; @@ -567,8 +566,8 @@ I740CopyMungedData(ScrnInfoPtr pScrn, } } else { - for (j = 0; j < h; j++) { - for (i = 0; i < w; i++) { + for (int j = 0; j < h; j++) { + for (int i = 0; i < w; i++) { dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) | (src3[i] << 8) | (src2[i] << 24); } |