More warning fixes
authorVitaly Novichkov <admin@wohlnet.ru>
Tue, 26 Nov 2019 17:00:50 +0300
changeset 1047ee23898a09a2
parent 1046 ff8e95ea57ec
child 1048 569f5be0f8ec
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
src/effect_position.c
src/effect_stereoreverse.c
src/effects_internal.c
src/effects_internal.h
src/mixer.c
src/music.c
     1.1 --- a/src/codecs/music_flac.c	Tue Nov 26 15:56:56 2019 +0300
     1.2 +++ b/src/codecs/music_flac.c	Tue Nov 26 17:00:50 2019 +0300
     1.3 @@ -647,11 +647,11 @@
     1.4  static int FLAC_Seek(void *context, double position)
     1.5  {
     1.6      FLAC_Music *music = (FLAC_Music *)context;
     1.7 -    double seek_sample = music->sample_rate * position;
     1.8 +    FLAC__uint64 seek_sample = (FLAC__uint64) (music->sample_rate * position);
     1.9  
    1.10      SDL_AudioStreamClear(music->stream);
    1.11      music->pcm_pos = seek_sample;
    1.12 -    if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)seek_sample)) {
    1.13 +    if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, seek_sample)) {
    1.14          if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) {
    1.15              flac.FLAC__stream_decoder_flush(music->flac_decoder);
    1.16          }
     2.1 --- a/src/effect_position.c	Tue Nov 26 15:56:56 2019 +0300
     2.2 +++ b/src/effect_position.c	Tue Nov 26 17:00:50 2019 +0300
     2.3 @@ -33,7 +33,7 @@
     2.4  #include "SDL_mixer.h"
     2.5  #include "mixer.h"
     2.6  
     2.7 -#define __MIX_INTERNAL_EFFECT__
     2.8 +#define MIX_INTERNAL_EFFECT__
     2.9  #include "effects_internal.h"
    2.10  
    2.11  /* profile code:
     3.1 --- a/src/effect_stereoreverse.c	Tue Nov 26 15:56:56 2019 +0300
     3.2 +++ b/src/effect_stereoreverse.c	Tue Nov 26 17:00:50 2019 +0300
     3.3 @@ -30,7 +30,7 @@
     3.4  #include "SDL.h"
     3.5  #include "SDL_mixer.h"
     3.6  
     3.7 -#define __MIX_INTERNAL_EFFECT__
     3.8 +#define MIX_INTERNAL_EFFECT__
     3.9  #include "effects_internal.h"
    3.10  
    3.11  /* profile code:
     4.1 --- a/src/effects_internal.c	Tue Nov 26 15:56:56 2019 +0300
     4.2 +++ b/src/effects_internal.c	Tue Nov 26 17:00:50 2019 +0300
     4.3 @@ -30,7 +30,7 @@
     4.4  #include <stdlib.h>
     4.5  #include "SDL_mixer.h"
     4.6  
     4.7 -#define __MIX_INTERNAL_EFFECT__
     4.8 +#define MIX_INTERNAL_EFFECT__
     4.9  #include "effects_internal.h"
    4.10  
    4.11  /* Should we favor speed over memory usage and/or quality of output? */
    4.12 @@ -74,7 +74,7 @@
    4.13              _Eff_volume_table = (void *) rc;
    4.14              for (volume = 0; volume < 256; volume++) {
    4.15                  for (sample = -128; sample < 128; sample ++) {
    4.16 -                    *rc = (Uint8)(((float) sample) * ((float) volume / 255.0))
    4.17 +                    *rc = (Uint8)(((float) sample) * ((float) volume / 255.0f))
    4.18                          + 128;
    4.19                      rc++;
    4.20                  }
    4.21 @@ -105,7 +105,7 @@
    4.22              _Eff_volume_table = (void *) rc;
    4.23              for (volume = 0; volume < 256; volume++) {
    4.24                  for (sample = -128; sample < 128; sample ++) {
    4.25 -                    *rc = (Sint8)(((float) sample) * ((float) volume / 255.0));
    4.26 +                    *rc = (Sint8)(((float) sample) * ((float) volume / 255.0f));
    4.27                      rc++;
    4.28                  }
    4.29              }
     5.1 --- a/src/effects_internal.h	Tue Nov 26 15:56:56 2019 +0300
     5.2 +++ b/src/effects_internal.h	Tue Nov 26 17:00:50 2019 +0300
     5.3 @@ -21,10 +21,10 @@
     5.4  
     5.5  /* $Id$ */
     5.6  
     5.7 -#ifndef _INCLUDE_EFFECTS_INTERNAL_H_
     5.8 -#define _INCLUDE_EFFECTS_INTERNAL_H_
     5.9 +#ifndef INCLUDE_EFFECTS_INTERNAL_H_
    5.10 +#define INCLUDE_EFFECTS_INTERNAL_H_
    5.11  
    5.12 -#ifndef __MIX_INTERNAL_EFFECT__
    5.13 +#ifndef MIX_INTERNAL_EFFECT__
    5.14  #error You should not include this file or use these functions.
    5.15  #endif
    5.16  
     6.1 --- a/src/mixer.c	Tue Nov 26 15:56:56 2019 +0300
     6.2 +++ b/src/mixer.c	Tue Nov 26 17:00:50 2019 +0300
     6.3 @@ -33,7 +33,7 @@
     6.4  #include "load_aiff.h"
     6.5  #include "load_voc.h"
     6.6  
     6.7 -#define __MIX_INTERNAL_EFFECT__
     6.8 +#define MIX_INTERNAL_EFFECT__
     6.9  #include "effects_internal.h"
    6.10  
    6.11  /* Magic numbers for various audio file formats */
    6.12 @@ -130,7 +130,7 @@
    6.13          }
    6.14      }
    6.15  
    6.16 -    ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char *));
    6.17 +    ptr = SDL_realloc((void *)chunk_decoders, (size_t)(num_decoders + 1) * sizeof (const char *));
    6.18      if (ptr == NULL) {
    6.19          return;  /* oh well, go on without it. */
    6.20      }
    6.21 @@ -236,11 +236,11 @@
    6.22      if (e != NULL) {    /* are there any registered effects? */
    6.23          /* if this is the postmix, we can just overwrite the original. */
    6.24          if (!posteffect) {
    6.25 -            buf = SDL_malloc(len);
    6.26 +            buf = SDL_malloc((size_t)len);
    6.27              if (buf == NULL) {
    6.28                  return(snd);
    6.29              }
    6.30 -            SDL_memcpy(buf, snd, len);
    6.31 +            SDL_memcpy(buf, snd, (size_t)len);
    6.32          }
    6.33  
    6.34          for (; e != NULL; e = e->next) {
    6.35 @@ -267,7 +267,7 @@
    6.36  
    6.37  #if SDL_VERSION_ATLEAST(1, 3, 0)
    6.38      /* Need to initialize the stream in SDL 1.3+ */
    6.39 -    SDL_memset(stream, mixer.silence, len);
    6.40 +    SDL_memset(stream, mixer.silence, (size_t)len);
    6.41  #endif
    6.42  
    6.43      /* Mix the music (must be done before the channels are added) */
    6.44 @@ -532,7 +532,7 @@
    6.45  static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
    6.46  {
    6.47      int i;
    6.48 -	Mix_MusicType music_type;
    6.49 +    Mix_MusicType music_type;
    6.50      Mix_MusicInterface *interface = NULL;
    6.51      void *music = NULL;
    6.52      Sint64 start;
    6.53 @@ -541,7 +541,7 @@
    6.54      int count = 0;
    6.55      int fragment_size;
    6.56  
    6.57 -	music_type = detect_music_type(src);
    6.58 +    music_type = detect_music_type(src);
    6.59      if (!load_music_type(music_type) || !open_music_type(music_type)) {
    6.60          return NULL;
    6.61      }
     7.1 --- a/src/music.c	Tue Nov 26 15:56:56 2019 +0300
     7.2 +++ b/src/music.c	Tue Nov 26 17:00:50 2019 +0300
     7.3 @@ -153,7 +153,7 @@
     7.4          }
     7.5      }
     7.6  
     7.7 -    ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *));
     7.8 +    ptr = SDL_realloc((void *)music_decoders, ((size_t)num_decoders + 1) * sizeof (const char *));
     7.9      if (ptr == NULL) {
    7.10          return;  /* oh well, go on without it. */
    7.11      }
    7.12 @@ -194,7 +194,7 @@
    7.13      if (volume == MIX_MAX_VOLUME) {
    7.14          dst = snd;
    7.15      } else {
    7.16 -        dst = SDL_stack_alloc(Uint8, bytes);
    7.17 +        dst = SDL_stack_alloc(Uint8, (size_t)bytes);
    7.18      }
    7.19      while (len > 0 && !done) {
    7.20          int consumed = GetSome(context, dst, len, &done);
    7.21 @@ -394,7 +394,7 @@
    7.22      Mix_VolumeMusic(MIX_MAX_VOLUME);
    7.23  
    7.24      /* Calculate the number of ms for each callback */
    7.25 -    ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq);
    7.26 +    ms_per_step = (int) (((float)spec->samples * 1000.0f) / spec->freq);
    7.27  }
    7.28  
    7.29  /* Return SDL_TRUE if the music type is available */