Fix build warnings

This commit is contained in:
wangqr 2019-04-12 13:50:50 -04:00
parent bf55264e6d
commit b6eebcd7ef
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)
: palette((3<<prec) + 3)
, factor(1<<prec)
, factor((size_t)1<<prec)
{
std::string opt_base = "Colour/Schemes/" + scheme_name + "/";
switch (static_cast<AudioRenderingStyle>(audio_rendering_style))

View File

@ -114,7 +114,7 @@ void AudioSpectrumRenderer::RecreateCache()
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);
#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));
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 );
o++;

View File

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