diff --git a/src/core/log.c b/src/core/log.c index 6af5724b9..118d6fff3 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -128,13 +128,13 @@ void mLogFilterSet(struct mLogFilter* filter, const char* category, int levels) } bool mLogFilterTest(struct mLogFilter* filter, int category, enum mLogLevel level) { - int value = (int) TableLookup(&filter->levels, category); + int value = (intptr_t) TableLookup(&filter->levels, category); if (value) { return value & level; } const char* cat = mLogCategoryId(category); if (cat) { - value = (int) HashTableLookup(&filter->categories, cat); + value = (intptr_t) HashTableLookup(&filter->categories, cat); if (value) { TableInsert(&filter->levels, category, (void*)(intptr_t) value); return value & level; diff --git a/src/core/tile-cache.c b/src/core/tile-cache.c index 2a7c8cf3a..d1e1b9e25 100644 --- a/src/core/tile-cache.c +++ b/src/core/tile-cache.c @@ -198,7 +198,7 @@ static inline color_t* _tileLookup(struct mTileCache* cache, unsigned tileId, un if (tileId >= tiles) { abort(); } - if (paletteId >= 1 << mTileCacheSystemInfoGetPaletteCount(cache->sysConfig)) { + if (paletteId >= 1U << mTileCacheSystemInfoGetPaletteCount(cache->sysConfig)) { abort(); } #endif diff --git a/src/gb/memory.c b/src/gb/memory.c index 688d43676..1761bcb39 100644 --- a/src/gb/memory.c +++ b/src/gb/memory.c @@ -178,6 +178,7 @@ void GBMemoryReset(struct GB* gb) { memset(&gb->memory.hram, 0, sizeof(gb->memory.hram)); GBMBCInit(gb); + memset(&gb->memory.mbcState, 0, sizeof(gb->memory.mbcState)); switch (gb->memory.mbcType) { case GB_MBC1: gb->memory.mbcState.mbc1.mode = 0; @@ -192,8 +193,9 @@ void GBMemoryReset(struct GB* gb) { case GB_MMM01: GBMBCSwitchBank0(gb, gb->memory.romSize / GB_SIZE_CART_BANK0 - 2); GBMBCSwitchBank(gb, gb->memory.romSize / GB_SIZE_CART_BANK0 - 1); + break; default: - memset(&gb->memory.mbcState, 0, sizeof(gb->memory.mbcState)); + break; } gb->memory.sramBank = gb->memory.sram; diff --git a/src/gb/timer.c b/src/gb/timer.c index ca2fe46d6..32c9efdc5 100644 --- a/src/gb/timer.c +++ b/src/gb/timer.c @@ -30,7 +30,7 @@ static void _GBTimerDivIncrement(struct GBTimer* timer, uint32_t cyclesLate) { mTimingSchedule(&timer->p->timing, &timer->irq, 7 - ((timer->p->cpu->executionState - cyclesLate) & 3)); } } - int timingFactor = 0x3FF >> !timer->p->doubleSpeed; + unsigned timingFactor = 0x3FF >> !timer->p->doubleSpeed; if ((timer->internalDiv & timingFactor) == timingFactor) { GBAudioUpdateFrame(&timer->p->audio, &timer->p->timing); } @@ -80,7 +80,6 @@ void GBTimerDivReset(struct GBTimer* timer) { mTimingSchedule(&timer->p->timing, &timer->irq, 7 - (timer->p->cpu->executionState & 3)); } } - int timingFactor = 0x200 >> !timer->p->doubleSpeed; if (timer->internalDiv & 0x200) { GBAudioUpdateFrame(&timer->p->audio, &timer->p->timing); } diff --git a/src/gba/gba.c b/src/gba/gba.c index 0e58f1618..d68a03c2e 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -512,7 +512,7 @@ void GBADebug(struct GBA* gba, uint16_t flags) { int level = 1 << GBADebugFlagsGetLevel(gba->debugFlags); level &= 0x1F; char oolBuf[0x101]; - strncpy(oolBuf, gba->debugString, sizeof(gba->debugString)); + strncpy(oolBuf, gba->debugString, sizeof(oolBuf) - 1); memset(gba->debugString, 0, sizeof(gba->debugString)); oolBuf[0x100] = '\0'; mLog(_mLOG_CAT_GBA_DEBUG(), level, "%s", oolBuf); diff --git a/src/gba/renderers/cache-set.c b/src/gba/renderers/cache-set.c index 343cdcb8e..dae92b675 100644 --- a/src/gba/renderers/cache-set.c +++ b/src/gba/renderers/cache-set.c @@ -158,10 +158,10 @@ void GBAVideoCacheWriteVideoRegister(struct mCacheSet* cache, uint32_t address, switch (address) { case REG_DISPCNT: GBAVideoCacheWriteDISPCNT(cache, value); - GBAVideoCacheWriteBGCNT(cache, 0, (uint16_t) mMapCacheSetGetPointer(&cache->maps, 0)->context); - GBAVideoCacheWriteBGCNT(cache, 1, (uint16_t) mMapCacheSetGetPointer(&cache->maps, 1)->context); - GBAVideoCacheWriteBGCNT(cache, 2, (uint16_t) mMapCacheSetGetPointer(&cache->maps, 2)->context); - GBAVideoCacheWriteBGCNT(cache, 3, (uint16_t) mMapCacheSetGetPointer(&cache->maps, 3)->context); + GBAVideoCacheWriteBGCNT(cache, 0, (uintptr_t) mMapCacheSetGetPointer(&cache->maps, 0)->context); + GBAVideoCacheWriteBGCNT(cache, 1, (uintptr_t) mMapCacheSetGetPointer(&cache->maps, 1)->context); + GBAVideoCacheWriteBGCNT(cache, 2, (uintptr_t) mMapCacheSetGetPointer(&cache->maps, 2)->context); + GBAVideoCacheWriteBGCNT(cache, 3, (uintptr_t) mMapCacheSetGetPointer(&cache->maps, 3)->context); break; case REG_BG0CNT: GBAVideoCacheWriteBGCNT(cache, 0, value); diff --git a/src/platform/python/engine.c b/src/platform/python/engine.c index e6b2c0cf6..67d1d7b49 100644 --- a/src/platform/python/engine.c +++ b/src/platform/python/engine.c @@ -65,7 +65,6 @@ bool mPythonScriptEngineInit(struct mScriptEngine* se, struct mScriptBridge* sb) } void mPythonScriptEngineDeinit(struct mScriptEngine* se) { - struct mPythonScriptEngine* engine = (struct mPythonScriptEngine*) se; free(se); } @@ -76,7 +75,7 @@ bool mPythonScriptEngineIsScript(struct mScriptEngine* se, const char* name, str } bool mPythonScriptEngineLoadScript(struct mScriptEngine* se, const char* name, struct VFile* vf) { - struct mPythonScriptEngine* engine = (struct mPythonScriptEngine*) se; + UNUSED(se); return mPythonLoadScript(name, vf); } @@ -94,7 +93,7 @@ void mPythonScriptEngineRun(struct mScriptEngine* se) { } bool mPythonScriptEngineLookupSymbol(struct mScriptEngine* se, const char* name, int32_t* out) { - struct mPythonScriptEngine* engine = (struct mPythonScriptEngine*) se; + UNUSED(se); return mPythonLookupSymbol(name, out); } diff --git a/src/platform/sdl/sdl-events.c b/src/platform/sdl/sdl-events.c index 97f58f229..00d6df378 100644 --- a/src/platform/sdl/sdl-events.c +++ b/src/platform/sdl/sdl-events.c @@ -304,7 +304,7 @@ void mSDLPlayerSaveConfig(const struct mSDLPlayer* context, struct Configuration #else const char* name = SDL_JoystickName(SDL_JoystickIndex(context->joystick->joystick)); #endif - char value[12]; + char value[16]; snprintf(value, sizeof(value), "%i", context->rotation.axisX); mInputSetCustomValue(config, "gba", SDL_BINDING_BUTTON, "tiltAxisX", value, name); snprintf(value, sizeof(value), "%i", context->rotation.axisY);