all repos — mgba @ dab12cf5c674542cae0db7708c333035255fbc65

mGBA Game Boy Advance Emulator

All: Fix several warnings
Vicki Pfau vi@endrift.com
Thu, 16 Jan 2020 19:43:28 -0800
commit

dab12cf5c674542cae0db7708c333035255fbc65

parent

8a6cf8dc9c00082e9917b4777f949de0d35ce710

M src/arm/debugger/cli-debugger.csrc/arm/debugger/cli-debugger.c

@@ -86,7 +86,7 @@ if (!dv || dv->type != CLIDV_INT_TYPE) {

size = 1; } else { size = dv->intValue; - dv = dv->next; // TODO: Check for excess args + // TODO: Check for excess args } int i;
M src/debugger/cli-debugger.csrc/debugger/cli-debugger.c

@@ -883,6 +883,7 @@ }

if (dvNext->type == CLIDV_ERROR_TYPE) { debugger->backend->printf(debugger->backend, "Parse error\n"); _DVFree(dv); + _DVFree(dvNext); return 0; }
M src/gb/extra/proxy.csrc/gb/extra/proxy.c

@@ -64,7 +64,7 @@ proxyRenderer->backend->cache = NULL;

} } -static void _reset(struct GBVideoProxyRenderer* proxyRenderer, enum GBModel model) { +static void _reset(struct GBVideoProxyRenderer* proxyRenderer) { memcpy(proxyRenderer->logger->oam, &proxyRenderer->d.oam->raw, GB_SIZE_OAM); memcpy(proxyRenderer->logger->vram, proxyRenderer->d.vram, GB_SIZE_VRAM);

@@ -83,7 +83,7 @@ renderer->d.cache = renderer->backend->cache;

renderer->d.vram = video->vram; renderer->d.oam = &video->oam; _init(renderer); - _reset(renderer, video->p->model); + _reset(renderer); } void GBVideoProxyRendererUnshim(struct GBVideo* video, struct GBVideoProxyRenderer* renderer) {
M src/gba/core.csrc/gba/core.c

@@ -354,6 +354,7 @@ #if defined(BUILD_GLES2) || defined(BUILD_GLES3)

struct GBACore* gbacore = (struct GBACore*) core; int scale = gbacore->glRenderer.scale; #else + UNUSED(core); int scale = 1; #endif

@@ -507,7 +508,7 @@ #if defined(BUILD_GLES2) || defined(BUILD_GLES3)

|| gbacore->glRenderer.outputTex != (unsigned) -1 #endif ) { - struct GBAVideoRenderer* renderer; + struct GBAVideoRenderer* renderer = NULL; if (gbacore->renderer.outputBuffer) { renderer = &gbacore->renderer.d; }

@@ -526,13 +527,15 @@ }

} #endif #ifndef MINIMAL_CORE - if (core->videoLogger) { + if (renderer && core->videoLogger) { gbacore->proxyRenderer.logger = core->videoLogger; GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer); renderer = &gbacore->proxyRenderer.d; } #endif - GBAVideoAssociateRenderer(&gba->video, renderer); + if (renderer) { + GBAVideoAssociateRenderer(&gba->video, renderer); + } } #ifndef MINIMAL_CORE

@@ -584,7 +587,7 @@ bios->close(bios);

bios = NULL; } } - if (bios) { + if (found && bios) { GBALoadBIOS(gba, bios); } }
M src/gba/renderers/gl.csrc/gba/renderers/gl.c

@@ -1161,7 +1161,6 @@ GBAVideoGLRendererWriteBGCNT(&glRenderer->bg[3], value);

break; case REG_BLDCNT: GBAVideoGLRendererWriteBLDCNT(glRenderer, value); - value &= 0x3FFF; break; case REG_BLDALPHA: glRenderer->blda = value & 0x1F;

@@ -1172,7 +1171,6 @@ glRenderer->bldb = (value >> 8) & 0x1F;

if (glRenderer->bldb > 0x10) { glRenderer->bldb = 0x10; } - value &= 0x1F1F; break; case REG_BLDY: glRenderer->bldy = value;

@@ -1505,7 +1503,10 @@ *pixels = glRenderer->temporaryBuffer;

} void GBAVideoGLRendererPutPixels(struct GBAVideoRenderer* renderer, size_t stride, const void* pixels) { - + // TODO + UNUSED(renderer); + UNUSED(stride); + UNUSED(pixels); } static void _enableBg(struct GBAVideoGLRenderer* renderer, int bg, bool active) {
M src/sm83/debugger/cli-debugger.csrc/sm83/debugger/cli-debugger.c

@@ -46,7 +46,7 @@ if (!dv || dv->type != CLIDV_INT_TYPE) {

size = 1; } else { size = dv->intValue; - dv = dv->next; // TODO: Check for excess args + // TODO: Check for excess args } size_t i;

@@ -57,7 +57,7 @@ }

static inline uint16_t _printLine(struct CLIDebugger* debugger, uint16_t address, int segment) { struct CLIDebuggerBackend* be = debugger->backend; - struct SM83InstructionInfo info = {0}; + struct SM83InstructionInfo info = {{0}, 0}; char disassembly[48]; char* disPtr = disassembly; if (segment >= 0) {
M src/util/gui.csrc/util/gui.c

@@ -16,7 +16,8 @@

void GUIPollInput(struct GUIParams* params, uint32_t* newInputOut, uint32_t* heldInput) { uint32_t input = params->pollInput(&params->keyMap); uint32_t newInput = 0; - for (int i = 0; i < GUI_INPUT_MAX; ++i) { + int i; + for (i = 0; i < GUI_INPUT_MAX; ++i) { if (input & (1 << i)) { ++params->inputHistory[i]; } else {

@@ -66,7 +67,8 @@ return params->cursorState;

} void GUIInvalidateKeys(struct GUIParams* params) { - for (int i = 0; i < GUI_INPUT_MAX; ++i) { + int i; + for (i = 0; i < GUI_INPUT_MAX; ++i) { params->inputHistory[i] = 0; } }
M src/util/hash.csrc/util/hash.c

@@ -60,7 +60,8 @@ // body

const uint32_t * blocks = (const uint32_t *)(data + nblocks*4); - for(int i = -nblocks; i; i++) + int i; + for(i = -nblocks; i; i++) { uint32_t k1 = getblock32(blocks,i);

@@ -82,10 +83,15 @@ uint32_t k1 = 0;

switch(len & 3) { - case 3: k1 ^= tail[2] << 16; - case 2: k1 ^= tail[1] << 8; - case 1: k1 ^= tail[0]; - k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; + case 3: + k1 ^= tail[2] << 16; + // Fall through + case 2: + k1 ^= tail[1] << 8; + // Fall through + case 1: + k1 ^= tail[0]; + k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; }; //----------
M src/util/string.csrc/util/string.c

@@ -234,8 +234,8 @@

extern const uint16_t gbkUnicodeTable[]; char* gbkToUtf8(const char* gbk, size_t length) { - char* utf8 = 0; - char* utf8Offset; + char* utf8 = NULL; + char* utf8Offset = NULL; size_t offset; uint8_t gbk1 = 0; char buffer[4];

@@ -266,17 +266,17 @@ }

size_t bytes = toUtf8(unichar, buffer); utf8Length += bytes; - if (utf8Length < utf8TotalBytes) { - memcpy(utf8Offset, buffer, bytes); - utf8Offset += bytes; - } else if (!utf8) { + if (!utf8) { utf8 = malloc(length); if (!utf8) { - return 0; + return NULL; } utf8TotalBytes = length; memcpy(utf8, buffer, bytes); utf8Offset = utf8 + bytes; + } else if (utf8Length < utf8TotalBytes) { + memcpy(utf8Offset, buffer, bytes); + utf8Offset += bytes; } else if (utf8Length >= utf8TotalBytes) { ptrdiff_t o = utf8Offset - utf8; char* newUTF8 = realloc(utf8, utf8TotalBytes * 2);
M src/util/vfs.csrc/util/vfs.c

@@ -199,7 +199,7 @@ size_t len = strlen(dotPoint);

if (PATH_MAX <= len) { len = PATH_MAX - 1; } - strncpy(extension, dotPoint, len); + strncpy(extension, dotPoint, PATH_MAX - 1); extension[len] = '\0'; } else { extension[0] = '\0';