From c3e7997f75d7c88e433da8780dfa7925125c7c4d Mon Sep 17 00:00:00 2001 From: Patryk Obara Date: Wed, 25 Dec 2019 15:50:44 +0100 Subject: [PATCH] Fix conversion warnings after SDL2 transition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detected by MSVC compiler; several warnings: "(…) conversion from 'Sint64' to '', possible loss of data" --- src/libs/decoders/SDL_sound.c | 2 +- src/libs/decoders/mp3_seek_table.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/decoders/SDL_sound.c b/src/libs/decoders/SDL_sound.c index 017a2a62..f71650cf 100644 --- a/src/libs/decoders/SDL_sound.c +++ b/src/libs/decoders/SDL_sound.c @@ -400,7 +400,7 @@ static int init_sample(const Sound_DecoderFunctions *funcs, { Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; Sound_AudioInfo desired; - int pos = SDL_RWtell(internal->rw); + const Sint64 pos = SDL_RWtell(internal->rw); /* fill in the funcs for this decoder... */ sample->decoder = &funcs->info; diff --git a/src/libs/decoders/mp3_seek_table.cpp b/src/libs/decoders/mp3_seek_table.cpp index a2606655..517d3da8 100644 --- a/src/libs/decoders/mp3_seek_table.cpp +++ b/src/libs/decoders/mp3_seek_table.cpp @@ -126,20 +126,20 @@ Uint64 calculate_stream_hash(struct SDL_RWops* const context) { // Seek to the end of the file so we can calculate the stream size. SDL_RWseek(context, 0, RW_SEEK_END); - const Sint32 stream_size = SDL_RWtell(context); + const Sint64 stream_size = SDL_RWtell(context); if (stream_size <= 0) { // LOG_MSG("MP3: get_stream_size returned %d, but should be positive", stream_size); return 0; } // Seek to the middle of the file while taking into account version small files. - const Uint32 tail_size = (stream_size > 32768) ? 32768 : stream_size; + const Sint64 tail_size = (stream_size > 32768) ? 32768 : stream_size; const Sint64 mid_pos = static_cast(stream_size/2.0) - tail_size; - SDL_RWseek(context, mid_pos >= 0 ? static_cast(mid_pos) : 0, RW_SEEK_SET); + SDL_RWseek(context, mid_pos >= 0 ? mid_pos : 0, RW_SEEK_SET); // Prepare our read buffer and counter: vector buffer(1024, 0); - Uint32 total_bytes_read = 0; + size_t total_bytes_read = 0; // Initialize xxHash's state using the stream_size as our seed. // Seeding with the stream_size provide a second level of uniqueness @@ -150,7 +150,7 @@ Uint64 calculate_stream_hash(struct SDL_RWops* const context) { const Uint64 seed = stream_size; XXH64_reset(state, seed); - while (total_bytes_read < tail_size) { + while (total_bytes_read < static_cast(tail_size)) { // Read a chunk of data. const size_t bytes_read = SDL_RWread(context, buffer.data(), 1, buffer.size()); @@ -164,7 +164,7 @@ Uint64 calculate_stream_hash(struct SDL_RWops* const context) { } // restore the stream position - SDL_RWseek(context, static_cast(original_pos), RW_SEEK_SET); + SDL_RWseek(context, original_pos, RW_SEEK_SET); const Uint64 hash = XXH64_digest(state); XXH64_freeState(state);