Fix build warnings

master
wangqr 2019-04-12 13:50:50 -04:00 committed by Thomas Goyne
parent faad82e1ec
commit 17215edc31
3 changed files with 10 additions and 7 deletions

View File

@ -37,7 +37,7 @@
AudioColorScheme::AudioColorScheme(int prec, std::string const& scheme_name, int audio_rendering_style) AudioColorScheme::AudioColorScheme(int prec, std::string const& scheme_name, int audio_rendering_style)
: palette((3<<prec) + 3) : palette((3<<prec) + 3)
, factor(1<<prec) , factor((size_t)1<<prec)
{ {
std::string opt_base = "Colour/Schemes/" + scheme_name + "/"; std::string opt_base = "Colour/Schemes/" + scheme_name + "/";
switch (static_cast<AudioRenderingStyle>(audio_rendering_style)) switch (static_cast<AudioRenderingStyle>(audio_rendering_style))

View File

@ -114,7 +114,7 @@ void AudioSpectrumRenderer::RecreateCache()
if (provider) if (provider)
{ {
size_t block_count = (size_t)((provider->GetNumSamples() + (size_t)(1<<derivation_dist) - 1) >> derivation_dist); size_t block_count = (size_t)((provider->GetNumSamples() + ((size_t)1<<derivation_dist) - 1) >> derivation_dist);
cache = agi::make_unique<AudioSpectrumCache>(block_count, this); cache = agi::make_unique<AudioSpectrumCache>(block_count, this);
#ifdef WITH_FFTW3 #ifdef WITH_FFTW3
@ -181,7 +181,7 @@ void AudioSpectrumRenderer::FillBlock(size_t block_index, float *block)
double scale_factor = 9 / sqrt(2 << (derivation_size + 1)); double scale_factor = 9 / sqrt(2 << (derivation_size + 1));
fftw_complex *o = dft_output; fftw_complex *o = dft_output;
for (size_t si = 1<<derivation_size; si > 0; --si) for (size_t si = (size_t)1<<derivation_size; si > 0; --si)
{ {
*block++ = log10( sqrt(o[0][0] * o[0][0] + o[0][1] * o[0][1]) * scale_factor + 1 ); *block++ = log10( sqrt(o[0][0] * o[0][0] + o[0][1] * o[0][1]) * scale_factor + 1 );
o++; o++;

View File

@ -81,8 +81,11 @@ void subhelp_vlog(enum csri_logging_severity severity,
n = vsnprintf(buffer, size, msg, args); n = vsnprintf(buffer, size, msg, args);
if (n >= 0 && (unsigned)n < size) if (n >= 0 && (unsigned)n < size)
break; break;
size = n > 0 ? (unsigned)n + 1 : size * 2; size = n > 0 ? (size_t)n + 1 : size * 2;
buffer = (char *)realloc(buffer, size); char* old_buffer = buffer;
buffer = (char *)realloc(old_buffer, size);
if (!buffer)
free(old_buffer);
} }
final = buffer ? buffer : "<out of memory in logging function>"; final = buffer ? buffer : "<out of memory in logging function>";
subhelp_slog(severity, final); subhelp_slog(severity, final);
@ -95,8 +98,8 @@ void subhelp_slog(enum csri_logging_severity severity, const char *msg)
if (logfunc) if (logfunc)
logfunc(appdata, severity, msg); logfunc(appdata, severity, msg);
else { else {
fprintf(stderr, msg); fputs(msg, stderr);
fprintf(stderr, "\n"); fputc('\n', stderr);
} }
} }