From babf6893c8e4b3c3474b8e9bd8f2ad8b4b0d452e Mon Sep 17 00:00:00 2001 From: Scott Allen Date: Mon, 24 Apr 2017 11:04:11 -0400 Subject: [PATCH] Eliminate "may be uninitialized" variable warning Code in Sprites.cpp refactored to eliminate "warning: 'mask_ofs' may be used uninitialized in this function" --- src/Sprites.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Sprites.cpp b/src/Sprites.cpp index 0b3dbe2..6c52e98 100644 --- a/src/Sprites.cpp +++ b/src/Sprites.cpp @@ -125,9 +125,6 @@ void Sprites::drawBitmap(int16_t x, int16_t y, sRow += start_h; ofs = (sRow * WIDTH) + x + xOffset; uint8_t *bofs = (uint8_t *)bitmap + (start_h * w) + xOffset; - uint8_t *mask_ofs; - if (mask != 0) - mask_ofs = (uint8_t *)mask + (start_h * w) + xOffset; uint8_t data; uint8_t mul_amt = 1 << yOffset; @@ -205,6 +202,8 @@ void Sprites::drawBitmap(int16_t x, int16_t y, break; case SPRITE_MASKED: + uint8_t *mask_ofs; + mask_ofs = (uint8_t *)mask + (start_h * w) + xOffset; for (uint8_t a = 0; a < loop_h; a++) { for (uint8_t iCol = 0; iCol < rendered_width; iCol++) { // NOTE: you might think in the yOffset==0 case that this results