From 840d849547f0bd59b3ba9b2dcdafb8c7a40e92ff Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Tue, 26 Nov 2019 17:00:50 +0300 Subject: [PATCH] More warning fixes - __MIX_INTERNAL_EFFECT__ -> MIX_INTERNAL_EFFECT__ ("reserved identifier") - add missing casts - change seek_sample from double to FLAC__uint64 in FLAC_Seek() - change 255.0 to 255.0f in float divisons - replace two tabs with 4 spaces in mixer.c --- src/codecs/music_flac.c | 4 ++-- src/effect_position.c | 2 +- src/effect_stereoreverse.c | 2 +- src/effects_internal.c | 6 +++--- src/effects_internal.h | 6 +++--- src/mixer.c | 14 +++++++------- src/music.c | 6 +++--- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/codecs/music_flac.c b/src/codecs/music_flac.c index 95a330d9..63effd1f 100644 --- a/src/codecs/music_flac.c +++ b/src/codecs/music_flac.c @@ -647,11 +647,11 @@ static int FLAC_GetAudio(void *context, void *data, int bytes) static int FLAC_Seek(void *context, double position) { FLAC_Music *music = (FLAC_Music *)context; - double seek_sample = music->sample_rate * position; + FLAC__uint64 seek_sample = (FLAC__uint64) (music->sample_rate * position); SDL_AudioStreamClear(music->stream); music->pcm_pos = seek_sample; - if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)seek_sample)) { + if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, seek_sample)) { if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) { flac.FLAC__stream_decoder_flush(music->flac_decoder); } diff --git a/src/effect_position.c b/src/effect_position.c index 5e2b708f..d1e6a5d2 100644 --- a/src/effect_position.c +++ b/src/effect_position.c @@ -33,7 +33,7 @@ #include "SDL_mixer.h" #include "mixer.h" -#define __MIX_INTERNAL_EFFECT__ +#define MIX_INTERNAL_EFFECT__ #include "effects_internal.h" /* profile code: diff --git a/src/effect_stereoreverse.c b/src/effect_stereoreverse.c index 5894c36e..d07bbaf7 100644 --- a/src/effect_stereoreverse.c +++ b/src/effect_stereoreverse.c @@ -30,7 +30,7 @@ #include "SDL.h" #include "SDL_mixer.h" -#define __MIX_INTERNAL_EFFECT__ +#define MIX_INTERNAL_EFFECT__ #include "effects_internal.h" /* profile code: diff --git a/src/effects_internal.c b/src/effects_internal.c index f56a84c5..06f6f5b7 100644 --- a/src/effects_internal.c +++ b/src/effects_internal.c @@ -30,7 +30,7 @@ #include #include "SDL_mixer.h" -#define __MIX_INTERNAL_EFFECT__ +#define MIX_INTERNAL_EFFECT__ #include "effects_internal.h" /* Should we favor speed over memory usage and/or quality of output? */ @@ -74,7 +74,7 @@ void *_Eff_build_volume_table_u8(void) _Eff_volume_table = (void *) rc; for (volume = 0; volume < 256; volume++) { for (sample = -128; sample < 128; sample ++) { - *rc = (Uint8)(((float) sample) * ((float) volume / 255.0)) + *rc = (Uint8)(((float) sample) * ((float) volume / 255.0f)) + 128; rc++; } @@ -105,7 +105,7 @@ void *_Eff_build_volume_table_s8(void) _Eff_volume_table = (void *) rc; for (volume = 0; volume < 256; volume++) { for (sample = -128; sample < 128; sample ++) { - *rc = (Sint8)(((float) sample) * ((float) volume / 255.0)); + *rc = (Sint8)(((float) sample) * ((float) volume / 255.0f)); rc++; } } diff --git a/src/effects_internal.h b/src/effects_internal.h index 6c8958ed..4f76479c 100644 --- a/src/effects_internal.h +++ b/src/effects_internal.h @@ -21,10 +21,10 @@ /* $Id$ */ -#ifndef _INCLUDE_EFFECTS_INTERNAL_H_ -#define _INCLUDE_EFFECTS_INTERNAL_H_ +#ifndef INCLUDE_EFFECTS_INTERNAL_H_ +#define INCLUDE_EFFECTS_INTERNAL_H_ -#ifndef __MIX_INTERNAL_EFFECT__ +#ifndef MIX_INTERNAL_EFFECT__ #error You should not include this file or use these functions. #endif diff --git a/src/mixer.c b/src/mixer.c index f2a6dc2c..134b7dd4 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -33,7 +33,7 @@ #include "load_aiff.h" #include "load_voc.h" -#define __MIX_INTERNAL_EFFECT__ +#define MIX_INTERNAL_EFFECT__ #include "effects_internal.h" /* Magic numbers for various audio file formats */ @@ -130,7 +130,7 @@ void add_chunk_decoder(const char *decoder) } } - ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char *)); + ptr = SDL_realloc((void *)chunk_decoders, (size_t)(num_decoders + 1) * sizeof (const char *)); if (ptr == NULL) { return; /* oh well, go on without it. */ } @@ -236,11 +236,11 @@ static void *Mix_DoEffects(int chan, void *snd, int len) if (e != NULL) { /* are there any registered effects? */ /* if this is the postmix, we can just overwrite the original. */ if (!posteffect) { - buf = SDL_malloc(len); + buf = SDL_malloc((size_t)len); if (buf == NULL) { return(snd); } - SDL_memcpy(buf, snd, len); + SDL_memcpy(buf, snd, (size_t)len); } for (; e != NULL; e = e->next) { @@ -267,7 +267,7 @@ mix_channels(void *udata, Uint8 *stream, int len) #if SDL_VERSION_ATLEAST(1, 3, 0) /* Need to initialize the stream in SDL 1.3+ */ - SDL_memset(stream, mixer.silence, len); + SDL_memset(stream, mixer.silence, (size_t)len); #endif /* Mix the music (must be done before the channels are added) */ @@ -532,7 +532,7 @@ typedef struct _MusicFragment static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) { int i; - Mix_MusicType music_type; + Mix_MusicType music_type; Mix_MusicInterface *interface = NULL; void *music = NULL; Sint64 start; @@ -541,7 +541,7 @@ static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpe int count = 0; int fragment_size; - music_type = detect_music_type(src); + music_type = detect_music_type(src); if (!load_music_type(music_type) || !open_music_type(music_type)) { return NULL; } diff --git a/src/music.c b/src/music.c index d7908ee8..d39dc990 100644 --- a/src/music.c +++ b/src/music.c @@ -153,7 +153,7 @@ static void add_music_decoder(const char *decoder) } } - ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *)); + ptr = SDL_realloc((void *)music_decoders, ((size_t)num_decoders + 1) * sizeof (const char *)); if (ptr == NULL) { return; /* oh well, go on without it. */ } @@ -194,7 +194,7 @@ int music_pcm_getaudio(void *context, void *data, int bytes, int volume, if (volume == MIX_MAX_VOLUME) { dst = snd; } else { - dst = SDL_stack_alloc(Uint8, bytes); + dst = SDL_stack_alloc(Uint8, (size_t)bytes); } while (len > 0 && !done) { int consumed = GetSome(context, dst, len, &done); @@ -394,7 +394,7 @@ void open_music(const SDL_AudioSpec *spec) Mix_VolumeMusic(MIX_MAX_VOLUME); /* Calculate the number of ms for each callback */ - ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq); + ms_per_step = (int) (((float)spec->samples * 1000.0f) / spec->freq); } /* Return SDL_TRUE if the music type is available */