All: Fix some undefined behavior warnings
Jeffrey Pfau jeffrey@endrift.com
Tue, 20 Oct 2015 22:29:59 -0700
9 files changed,
10 insertions(+),
9 deletions(-)
M
CHANGES
→
CHANGES
@@ -47,6 +47,7 @@ - GBA Config: Add "override" layer for better one-time configuration
- SDL: Allow GBASDLAudio to be used without a thread context - All: Improved PowerPC support - All: Add --version flag + - All: Fix some undefined behavior warnings 0.3.0: (2015-08-16) Features:
M
src/arm/isa-thumb.c
→
src/arm/isa-thumb.c
@@ -308,7 +308,7 @@
#define DEFINE_CONDITIONAL_BRANCH_THUMB(COND) \ DEFINE_INSTRUCTION_THUMB(B ## COND, \ if (ARM_COND_ ## COND) { \ - int8_t immediate = opcode; \ + uint8_t immediate = opcode; \ cpu->gprs[ARM_PC] += immediate << 1; \ THUMB_WRITE_PC; \ })
M
src/gba/audio.c
→
src/gba/audio.c
@@ -523,7 +523,7 @@ } else {
channel->dmaSource = 0; } } - CircleBufferRead8(&channel->fifo, &channel->sample); + CircleBufferRead8(&channel->fifo, (int8_t*) &channel->sample); } #if RESAMPLE_LIBRARY != RESAMPLE_BLIP_BUF
M
src/gba/audio.h
→
src/gba/audio.h
@@ -135,7 +135,7 @@
struct GBAAudioFIFO { struct CircleBuffer fifo; int dmaSource; - int8_t sample; + uint8_t sample; }; DECL_BITFIELD(GBARegisterSOUNDCNT_LO, uint16_t);
M
src/gba/renderers/software-mode0.c
→
src/gba/renderers/software-mode0.c
@@ -468,7 +468,7 @@ int localY;
unsigned xBase; - int flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; + uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; flags |= FLAG_TARGET_2 * background->target2; int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->objwin.packed)); objwinFlags |= flags;
M
src/gba/renderers/software-obj.c
→
src/gba/renderers/software-obj.c
@@ -140,7 +140,7 @@ int end = renderer->end;
uint32_t flags = GBAObjAttributesCGetPriority(sprite->c) << OFFSET_PRIORITY; flags |= FLAG_TARGET_1 * ((GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && renderer->target1Obj && renderer->blendEffect == BLEND_ALPHA) || GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_SEMITRANSPARENT); flags |= FLAG_OBJWIN * (GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_OBJWIN); - int32_t x = GBAObjAttributesBGetX(sprite->b) << 23; + int32_t x = (uint32_t) GBAObjAttributesBGetX(sprite->b) << 23; x >>= 23; uint16_t* vramBase = &renderer->d.vram[BASE_TILE >> 1]; unsigned charBase = GBAObjAttributesCGetTile(sprite->c) * 0x20;
M
src/gba/renderers/software-private.h
→
src/gba/renderers/software-private.h
@@ -177,7 +177,7 @@ } \
int32_t localX; \ int32_t localY; \ \ - int flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; \ + uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; \ flags |= FLAG_TARGET_2 * background->target2; \ int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \ GBAWindowControlIsBlendEnable(renderer->objwin.packed)); \
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -772,7 +772,7 @@ }
} } - int priority; + unsigned priority; for (priority = 0; priority < 4; ++priority) { renderer->end = 0; for (w = 0; w < renderer->nWindows; ++w) {
M
src/gba/renderers/video-software.h
→
src/gba/renderers/video-software.h
@@ -23,9 +23,9 @@ int endY;
}; struct GBAVideoSoftwareBackground { - int index; + unsigned index; int enabled; - int priority; + unsigned priority; uint32_t charBase; int mosaic; int multipalette;