GBA Video: Fix some undefined behavior in shifts
Vicki Pfau vi@endrift.com
Tue, 28 Jul 2020 15:43:01 -0700
2 files changed,
4 insertions(+),
4 deletions(-)
M
src/feature/video-logger.c
→
src/feature/video-logger.c
@@ -182,7 +182,7 @@ logger->writeData(logger, &dirty, sizeof(dirty));
} void mVideoLoggerRendererWriteVRAM(struct mVideoLogger* logger, uint32_t address) { - int bit = 1 << (address >> 12); + int bit = 1U << (address >> 12); if (logger->vramDirtyBitmap[address >> 17] & bit) { return; }
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -13,8 +13,8 @@
#include <mgba-util/arm-algo.h> #include <mgba-util/memory.h> -#define DIRTY_SCANLINE(R, Y) R->scanlineDirty[Y >> 5] |= (1 << (Y & 0x1F)) -#define CLEAN_SCANLINE(R, Y) R->scanlineDirty[Y >> 5] &= ~(1 << (Y & 0x1F)) +#define DIRTY_SCANLINE(R, Y) R->scanlineDirty[Y >> 5] |= (1U << (Y & 0x1F)) +#define CLEAN_SCANLINE(R, Y) R->scanlineDirty[Y >> 5] &= ~(1U << (Y & 0x1F)) static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer); static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer);@@ -519,7 +519,7 @@ } else {
softwareRenderer->nextY = y + 1; } - bool dirty = softwareRenderer->scanlineDirty[y >> 5] & (1 << (y & 0x1F)); + bool dirty = softwareRenderer->scanlineDirty[y >> 5] & (1U << (y & 0x1F)); if (memcmp(softwareRenderer->nextIo, softwareRenderer->cache[y].io, sizeof(softwareRenderer->nextIo))) { memcpy(softwareRenderer->cache[y].io, softwareRenderer->nextIo, sizeof(softwareRenderer->nextIo)); dirty = true;