Skip to content

Commit

Permalink
Warning fixes/supressions
Browse files Browse the repository at this point in the history
With this there are no more warnings when compiling with mingw and with
clang from android-ndk.

There are some remaining implicit declaration and int conversion
warnings in libretro-common when compiling using latest gcc on linux.
But maybe they should be first fixed first in the upstream
libretro-common so they are not reintroduced later on.
  • Loading branch information
Ferk committed Aug 26, 2019
1 parent d469c08 commit ea465fb
Show file tree
Hide file tree
Showing 16 changed files with 2,017 additions and 214 deletions.
4 changes: 2 additions & 2 deletions deps/libmad/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
if (!stream->sync)
ptr = stream->this_frame;

if (end - ptr < stream->skiplen) {
if ((unsigned)(end - ptr) < stream->skiplen) {
stream->skiplen -= end - ptr;
stream->next_frame = end;

Expand Down Expand Up @@ -384,7 +384,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
}

/* verify there is enough data left in buffer to decode this frame */
if (N + MAD_BUFFER_GUARD > end - stream->this_frame) {
if (N + MAD_BUFFER_GUARD > (unsigned)(end - stream->this_frame)) {
stream->next_frame = stream->this_frame;

stream->error = MAD_ERROR_BUFLEN;
Expand Down
6 changes: 3 additions & 3 deletions deps/libmad/layer3.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp)
exp += power->exponent;

if (exp < 0) {
if (-exp >= sizeof(mad_fixed_t) * CHAR_BIT) {
if (-exp >= (int)sizeof(mad_fixed_t) * CHAR_BIT) {
/* underflow */
requantized = 0;
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576],
break;

case 15:
if (cachesz < linbits + 2) {
if (cachesz < (int)linbits + 2) {
bitcache = (bitcache << 16) | mad_bit_read(&peek, 16);
cachesz += 16;
bits_left -= 16;
Expand Down Expand Up @@ -1070,7 +1070,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576],
break;

case 15:
if (cachesz < linbits + 1) {
if (cachesz < (int)linbits + 1) {
bitcache = (bitcache << 16) | mad_bit_read(&peek, 16);
cachesz += 16;
bits_left -= 16;
Expand Down
15 changes: 8 additions & 7 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static void extract_directory(char *buf, const char *path, size_t size)
static char* remove_extension(char *buf, const char *path, size_t size)
{
char *base;
strncpy(buf, path, size - 1);
memcpy(buf, path, size - 1);
buf[size - 1] = '\0';

base = strrchr(buf, '.');
Expand All @@ -515,7 +515,8 @@ static wadinfo_t get_wadinfo(const char *path)
wadinfo_t header;
if (fp != NULL)
{
fread(&header, sizeof(header), 1, fp);
if(fread(&header, sizeof(header), 1, fp) != 1)
I_Error("get_wadinfo: error reading file header");
fclose(fp);
}
else
Expand All @@ -542,7 +543,7 @@ bool retro_load_game(const struct retro_game_info *info)
wadinfo_t header;
char *deh, *extension, *baseconfig;

char name_without_ext[4096];
char name_without_ext[1023];
bool use_external_savedir = false;
const char *base_save_dir = NULL;

Expand All @@ -559,7 +560,8 @@ bool retro_load_game(const struct retro_game_info *info)
else
{
header = get_wadinfo(info->path);
if(header.identification == NULL)
// header.identification is static array, always non-NULL, but it might be empty if it couldn't be read
if(header.identification[0] == 0)
{
I_Error("retro_load_game: couldn't read WAD header from '%s'", info->path);
goto failed;
Expand All @@ -574,9 +576,8 @@ bool retro_load_game(const struct retro_game_info *info)
argv[argc++] = strdup("-file");
argv[argc++] = strdup(info->path);
}
else
{
I_Error("retro_load_game: invalid WAD header '%s'", header.identification);
else {
I_Error("retro_load_game: invalid WAD header '%.*s'", 4, header.identification);
goto failed;
}

Expand Down
9 changes: 5 additions & 4 deletions libretro/libretro_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ static void* I_SndLoadSample (const char* sfxname, int* len)
{
int i, x, padded_sfx_len, sfxlump_num, sfxlump_len;
char sfxlump_name[20];
uint8_t *sfxlump_data, *sfxlump_sound, *padded_sfx_data;
const uint8_t *sfxlump_data, *sfxlump_sound;
uint8_t *padded_sfx_data;
uint16_t orig_rate;
float times;

Expand Down Expand Up @@ -185,7 +186,7 @@ static void* I_SndLoadSample (const char* sfxname, int* len)
padded_sfx_data[i] = 128; // fill the rest with silence
}

Z_Free (sfxlump_data); // free original lump
Z_Free ((void*) sfxlump_data); // free original lump

*len = padded_sfx_len;
return (void *)(padded_sfx_data);
Expand Down Expand Up @@ -619,7 +620,7 @@ int I_RegisterSong(const void* data, size_t len)
{
music_handle = music_players[i]->registersong(data, len);
if (music_handle) {
current_player = music_players[i];
current_player = (music_player_t*)music_players[i];
break;
}
}
Expand Down Expand Up @@ -673,7 +674,7 @@ int I_RegisterSong(const void* data, size_t len)
mem_get_buf(outstream, &outbuf, &outbuf_len);
music_handle = opl_synth_player.registersong(outbuf, outbuf_len);
if(music_handle)
current_player = &opl_synth_player;
current_player = (music_player_t*)&opl_synth_player;
}

mem_fclose(instream);
Expand Down
4 changes: 2 additions & 2 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ static void AM_maxOutWindowScale(void)
boolean AM_Responder
( event_t* ev )
{
static int cheatstate=0;
//static int cheatstate=0;
static int bigstate=0;
int ch; // phares
int rc = FALSE;
Expand Down Expand Up @@ -694,7 +694,7 @@ boolean AM_Responder
}
else // phares
{
cheatstate=0;
//cheatstate=0;
rc = FALSE;
}
}
Expand Down
Loading

0 comments on commit ea465fb

Please sign in to comment.