Skip to content

Commit

Permalink
enable -Wall and fix warnings reported by it
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Sep 5, 2011
1 parent eb3668f commit bbba320
Show file tree
Hide file tree
Showing 23 changed files with 294 additions and 285 deletions.
2 changes: 0 additions & 2 deletions arm/arm_emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ u32 arm_disect_imm_32bit(u32 imm, u32 *stores, u32 *rotations)
{
u32 store_count = 0;
u32 left_shift = 0;
u32 i;

// Otherwise it'll return 0 things to store because it'll never
// find anything.
Expand Down Expand Up @@ -276,7 +275,6 @@ u32 arm_disect_imm_32bit(u32 imm, u32 *stores, u32 *rotations)
{
// Then we can throw out the last bit and tack it on
// to the first bit.
u32 initial_bits = rotations[0];
stores[0] =
(stores[0] << ((top_bits + (32 - rotations[0])) & 0x1F)) |
((imm >> left_shift) & 0xFF);
Expand Down
15 changes: 9 additions & 6 deletions cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ u32 num_cheats;
void decrypt_gsa_code(u32 *address_ptr, u32 *value_ptr, cheat_variant_enum
cheat_variant)
{
u32 i, i2, code_position;
u32 i;
u32 address = *address_ptr;
u32 value = *value_ptr;
u32 r = 0xc6ef3720;
Expand Down Expand Up @@ -58,11 +58,11 @@ void decrypt_gsa_code(u32 *address_ptr, u32 *value_ptr, cheat_variant_enum
*value_ptr = value;
}

void add_cheats(u8 *cheats_filename)
void add_cheats(char *cheats_filename)
{
FILE *cheats_file;
u8 current_line[256];
u8 *name_ptr;
char current_line[256];
char *name_ptr;
u32 *cheat_code_ptr;
u32 address, value;
u32 num_cheat_lines;
Expand Down Expand Up @@ -110,8 +110,8 @@ void add_cheats(u8 *cheats_filename)
cheats[num_cheats].cheat_name[CHEAT_NAME_LENGTH - 1] = 0;
cheat_name_length = strlen(cheats[num_cheats].cheat_name);
if(cheat_name_length &&
(cheats[num_cheats].cheat_name[cheat_name_length - 1] == '\n') ||
(cheats[num_cheats].cheat_name[cheat_name_length - 1] == '\r'))
((cheats[num_cheats].cheat_name[cheat_name_length - 1] == '\n') ||
(cheats[num_cheats].cheat_name[cheat_name_length - 1] == '\r')))
{
cheats[num_cheats].cheat_name[cheat_name_length - 1] = 0;
cheat_name_length--;
Expand Down Expand Up @@ -382,6 +382,9 @@ void process_cheats()
case CHEAT_TYPE_GAMESHARK_V3:
process_cheat_gs3(cheats + i);
break;

default:
break;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ typedef enum

typedef struct
{
u8 cheat_name[CHEAT_NAME_LENGTH];
char cheat_name[CHEAT_NAME_LENGTH];
u32 cheat_active;
u32 cheat_codes[256];
u32 num_cheat_lines;
cheat_variant_enum cheat_variant;
} cheat_type;

void process_cheats();
void add_cheats(u8 *cheats_filename);
void add_cheats(char *cheats_filename);

#define MAX_CHEATS 16

Expand Down
51 changes: 27 additions & 24 deletions cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void print_register_usage()


#define calculate_reg_sh() \
u32 reg_sh; \
u32 reg_sh = 0; \
switch((opcode >> 4) & 0x07) \
{ \
/* LSL imm */ \
Expand Down Expand Up @@ -451,7 +451,7 @@ void print_register_usage()
} \

#define calculate_reg_sh_flags() \
u32 reg_sh; \
u32 reg_sh = 0; \
switch((opcode >> 4) & 0x07) \
{ \
/* LSL imm */ \
Expand Down Expand Up @@ -604,7 +604,7 @@ void print_register_usage()
} \

#define calculate_reg_offset() \
u32 reg_offset; \
u32 reg_offset = 0; \
switch((opcode >> 5) & 0x03) \
{ \
/* LSL imm */ \
Expand Down Expand Up @@ -960,7 +960,7 @@ const u32 psr_masks[16] =
else \
\
if(((_address & aligned_address_mask##size) == 0) && \
(map = memory_map_read[address >> 15])) \
(map = memory_map_read[_address >> 15])) \
{ \
dest = *((type *)((u8 *)map + (_address & 0x7FFF))); \
} \
Expand Down Expand Up @@ -1016,37 +1016,39 @@ const u32 psr_masks[16] =

#define load_aligned32(address, dest) \
{ \
u8 *map = memory_map_read[address >> 15]; \
if(address < 0x10000000) \
u32 _address = address; \
u8 *map = memory_map_read[_address >> 15]; \
if(_address < 0x10000000) \
{ \
memory_region_access_read_u32[address >> 24]++; \
memory_region_access_read_u32[_address >> 24]++; \
memory_reads_u32++; \
} \
if(map) \
{ \
dest = address32(map, address & 0x7FFF); \
dest = address32(map, _address & 0x7FFF); \
} \
else \
{ \
dest = read_memory32(address); \
dest = read_memory32(_address); \
} \
} \

#define store_aligned32(address, value) \
{ \
u8 *map = memory_map_write[address >> 15]; \
if(address < 0x10000000) \
u32 _address = address; \
u8 *map = memory_map_write[_address >> 15]; \
if(_address < 0x10000000) \
{ \
memory_region_access_write_u32[address >> 24]++; \
memory_region_access_write_u32[_address >> 24]++; \
memory_writes_u32++; \
} \
if(map) \
{ \
address32(map, address & 0x7FFF) = value; \
address32(map, _address & 0x7FFF) = value; \
} \
else \
{ \
cpu_alert = write_memory32(address, value); \
cpu_alert = write_memory32(_address, value); \
if(cpu_alert) \
goto alert; \
} \
Expand Down Expand Up @@ -1233,15 +1235,15 @@ const u32 psr_masks[16] =
const u32 _sa = src_a; \
const u32 _sb = src_b; \
u32 dest = _sa + _sb; \
calculate_flags_add(dest, src_a, src_b); \
calculate_flags_add(dest, _sa, _sb); \
reg[dest_reg] = dest; \
thumb_pc_offset(2); \
} \

#define thumb_add_noflags(type, dest_reg, src_a, src_b) \
{ \
thumb_decode_##type(); \
u32 dest = src_a + src_b; \
u32 dest = (src_a) + (src_b); \
reg[dest_reg] = dest; \
thumb_pc_offset(2); \
} \
Expand All @@ -1252,7 +1254,7 @@ const u32 psr_masks[16] =
const u32 _sa = src_a; \
const u32 _sb = src_b; \
u32 dest = _sa - _sb; \
calculate_flags_sub(dest, src_a, src_b); \
calculate_flags_sub(dest, _sa, _sb); \
reg[dest_reg] = dest; \
thumb_pc_offset(2); \
} \
Expand Down Expand Up @@ -4058,19 +4060,19 @@ u32 last_instruction = 0;

u32 in_interrupt = 0;

u32 debug_on()
void debug_on()
{
current_debug_state = STEP;
debug_screen_start();
}

u32 debug_off(debug_state new_debug_state)
void debug_off(debug_state new_debug_state)
{
current_debug_state = new_debug_state;
debug_screen_end();
}

u32 function_cc step_debug(u32 pc, u32 cycles)
void function_cc step_debug(u32 pc, u32 cycles)
{
u32 thumb = 0;

Expand Down Expand Up @@ -4134,6 +4136,9 @@ u32 function_cc step_debug(u32 pc, u32 cycles)

break;
}

default:
break;
}

if((current_debug_state == STEP) ||
Expand Down Expand Up @@ -4263,7 +4268,7 @@ u32 function_cc step_debug(u32 pc, u32 cycles)

case 'a':
{
u8 current_savestate_filename[512];
char current_savestate_filename[512];
u16 *current_screen = copy_screen();
get_savestate_filename_noshot(savestate_slot,
current_savestate_filename);
Expand All @@ -4286,8 +4291,6 @@ u32 function_cc step_debug(u32 pc, u32 cycles)
reg[REG_PC] = pc + 2;
else
reg[REG_PC] = pc + 4;

return 0;
}

void set_cpu_mode(cpu_mode_type new_mode)
Expand Down Expand Up @@ -4352,7 +4355,7 @@ void raise_interrupt(irq_type irq_raised)
}
}

u32 execute_arm(u32 cycles)
void execute_arm(u32 cycles)
{
u32 pc = reg[REG_PC];
u32 opcode;
Expand Down
6 changes: 4 additions & 2 deletions cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ extern debug_state current_debug_state;
extern u32 instruction_count;
extern u32 last_instruction;

u32 function_cc step_debug(u32 pc, u32 cycles);
u32 execute_arm(u32 cycles);
void execute_arm(u32 cycles);
void raise_interrupt(irq_type irq_raised);
void set_cpu_mode(cpu_mode_type new_mode);

void debug_on();
void debug_off(debug_state new_debug_state);

u32 function_cc execute_load_u8(u32 address);
u32 function_cc execute_load_u16(u32 address);
u32 function_cc execute_load_u32(u32 address);
Expand Down
8 changes: 4 additions & 4 deletions cpu_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -3177,7 +3177,7 @@ block_exit_type block_exits[MAX_EXITS];
s32 translate_block_##type(u32 pc, translation_region_type \
translation_region, u32 smc_enable) \
{ \
u32 opcode; \
u32 opcode = 0; \
u32 last_opcode; \
u32 condition; \
u32 last_condition; \
Expand All @@ -3192,9 +3192,9 @@ s32 translate_block_##type(u32 pc, translation_region_type \
u32 branch_target; \
u32 cycle_count = 0; \
u8 *translation_target; \
u8 *backpatch_address; \
u8 *translation_ptr; \
u8 *translation_cache_limit; \
u8 *backpatch_address = NULL; \
u8 *translation_ptr = NULL; \
u8 *translation_cache_limit = NULL; \
s32 i; \
u32 flag_status; \
block_exit_type external_block_exits[MAX_EXITS]; \
Expand Down
4 changes: 4 additions & 0 deletions font.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define FONT_WIDTH 6
#define FONT_HEIGHT 10

#ifdef WANT_FONT_BITS

/* Font information:
name: 6x10
facename: -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO8859-1
Expand Down Expand Up @@ -5876,3 +5878,5 @@ static unsigned long _font_offset[256] =
2210, /* (0xfe) */
2220 /* (0xff) */
};

#endif /* WANT_FONT_BITS */
8 changes: 6 additions & 2 deletions gp2x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CFLAGS += -DWIZ_BUILD
endif
# NOTE: -funroll-loops will slow down compiling considerably
CFLAGS += -O3 -std=c99 -msoft-float -funsigned-char -fno-common \
-fno-builtin \
-fno-builtin -Wall \

INCLUDES = `$(PREFIX)/bin/sdl-config --cflags` -I$(PREFIX)/include
LIBS = `$(PREFIX)/bin/sdl-config --libs` \
Expand All @@ -42,6 +42,10 @@ endif

.SUFFIXES: .c

all: $(BIN)

cpu.o cpu_threaded.z: CFLAGS += -Wno-unused-variable -Wno-unused-label

%.z: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<

Expand All @@ -57,7 +61,7 @@ endif
%.o: %.s
$(CC) $(ASFLAGS) $(INCLUDES) -c -o $@ $<

all: $(OBJS)
$(BIN): $(OBJS)
$(CC) $(OBJS) $(LIBS) -o $(BIN)
$(STRIP) $(BIN)

Expand Down
2 changes: 2 additions & 0 deletions gp2x/gp2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

static u32 gpsp_gp2x_dev_audio;
static u32 gpsp_gp2x_dev;
#ifdef WIZ_BUILD
static u32 gpsp_gp2x_gpiodev;
#endif

static u32 gp2x_audio_volume = 74/2;

Expand Down
Loading

0 comments on commit bbba320

Please sign in to comment.