mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-06-02 18:11:19 +00:00
Merge pull request #586 from FluidSynth/typecheck-fluid-log
Improve type-checking of fluid_log() format specifiers
This commit is contained in:
commit
56e0cfd7c1
5 changed files with 21 additions and 17 deletions
|
@ -77,7 +77,11 @@ fluid_log_function_t fluid_set_log_function(int level, fluid_log_function_t fun,
|
||||||
|
|
||||||
FLUIDSYNTH_API void fluid_default_log_function(int level, const char *message, void *data);
|
FLUIDSYNTH_API void fluid_default_log_function(int level, const char *message, void *data);
|
||||||
|
|
||||||
FLUIDSYNTH_API int fluid_log(int level, const char *fmt, ...);
|
FLUIDSYNTH_API int fluid_log(int level, const char *fmt, ...)
|
||||||
|
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
||||||
|
__attribute__ ((format (printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -328,7 +328,7 @@ fluid_jack_client_register_ports(void *driver, int isaudio, jack_client_t *clien
|
||||||
char name[64];
|
char name[64];
|
||||||
int multi;
|
int multi;
|
||||||
int i;
|
int i;
|
||||||
int jack_srate;
|
unsigned long jack_srate;
|
||||||
double sample_rate;
|
double sample_rate;
|
||||||
|
|
||||||
if(!isaudio)
|
if(!isaudio)
|
||||||
|
@ -491,10 +491,10 @@ fluid_jack_client_register_ports(void *driver, int isaudio, jack_client_t *clien
|
||||||
|
|
||||||
fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate);
|
fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate);
|
||||||
|
|
||||||
if((int)sample_rate != jack_srate)
|
if((unsigned long)sample_rate != jack_srate)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_INFO, "Jack sample rate mismatch, adjusting."
|
FLUID_LOG(FLUID_INFO, "Jack sample rate mismatch, adjusting."
|
||||||
" (synth.sample-rate=%lu, jackd=%lu)", (int)sample_rate, jack_srate);
|
" (synth.sample-rate=%lu, jackd=%lu)", (unsigned long)sample_rate, jack_srate);
|
||||||
fluid_settings_setnum(settings, "synth.sample-rate", jack_srate);
|
fluid_settings_setnum(settings, "synth.sample-rate", jack_srate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ fluid_file_read_full(fluid_file fp, size_t *length)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUID_LOG(FLUID_DBG, "File load: Allocating %d bytes", buflen);
|
FLUID_LOG(FLUID_DBG, "File load: Allocating %lu bytes", buflen);
|
||||||
buffer = FLUID_MALLOC(buflen);
|
buffer = FLUID_MALLOC(buflen);
|
||||||
|
|
||||||
if(buffer == NULL)
|
if(buffer == NULL)
|
||||||
|
@ -193,7 +193,7 @@ fluid_file_read_full(fluid_file fp, size_t *length)
|
||||||
|
|
||||||
if(n != buflen)
|
if(n != buflen)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Only read %d bytes; expected %d", n,
|
FLUID_LOG(FLUID_ERR, "Only read %lu bytes; expected %lu", n,
|
||||||
buflen);
|
buflen);
|
||||||
FLUID_FREE(buffer);
|
FLUID_FREE(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -796,7 +796,7 @@ static int process_info(SFData *sf, int size)
|
||||||
if((chunk.id != ICMT_FCC && chunk.size > 256) || (chunk.size > 65536) || (chunk.size % 2))
|
if((chunk.id != ICMT_FCC && chunk.size > 256) || (chunk.size > 65536) || (chunk.size % 2))
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "INFO sub chunk %.4s has invalid chunk size of %d bytes",
|
FLUID_LOG(FLUID_ERR, "INFO sub chunk %.4s has invalid chunk size of %d bytes",
|
||||||
&chunk.id, chunk.size);
|
(char*)&chunk.id, chunk.size);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,19 +930,19 @@ static int pdtahelper(SFData *sf, unsigned int expid, unsigned int reclen, SFChu
|
||||||
|
|
||||||
if(chunk->id != expid)
|
if(chunk->id != expid)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Expected PDTA sub-chunk '%.4s' found invalid id instead", &expid);
|
FLUID_LOG(FLUID_ERR, "Expected PDTA sub-chunk '%.4s' found invalid id instead", (char*)&expid);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chunk->size % reclen) /* valid chunk size? */
|
if(chunk->size % reclen) /* valid chunk size? */
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "'%.4s' chunk size is not a multiple of %d bytes", &expid, reclen);
|
FLUID_LOG(FLUID_ERR, "'%.4s' chunk size is not a multiple of %d bytes", (char*)&expid, reclen);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((*size -= chunk->size) < 0)
|
if((*size -= chunk->size) < 0)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "'%.4s' chunk size exceeds remaining PDTA chunk size", &expid);
|
FLUID_LOG(FLUID_ERR, "'%.4s' chunk size exceeds remaining PDTA chunk size", (char*)&expid);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2615,7 +2615,7 @@ static int fluid_sffile_read_vorbis(SFData *sf, unsigned int start_byte, unsigne
|
||||||
|
|
||||||
if(!sndfile)
|
if(!sndfile)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, sf_strerror(sndfile));
|
FLUID_LOG(FLUID_ERR, "%s", sf_strerror(sndfile));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2642,7 +2642,7 @@ static int fluid_sffile_read_vorbis(SFData *sf, unsigned int start_byte, unsigne
|
||||||
if(sf_readf_short(sndfile, wav_data, sfinfo.frames) < sfinfo.frames)
|
if(sf_readf_short(sndfile, wav_data, sfinfo.frames) < sfinfo.frames)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_DBG, "Decompression failed!");
|
FLUID_LOG(FLUID_DBG, "Decompression failed!");
|
||||||
FLUID_LOG(FLUID_ERR, sf_strerror(sndfile));
|
FLUID_LOG(FLUID_ERR, "%s", sf_strerror(sndfile));
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1481,7 +1481,7 @@ static fluid_thread_return_t fluid_server_socket_run(void *data)
|
||||||
{
|
{
|
||||||
if(server_socket->cont)
|
if(server_socket->cont)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Failed to accept connection: %ld", fluid_socket_get_error());
|
FLUID_LOG(FLUID_ERR, "Failed to accept connection: %d", fluid_socket_get_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
server_socket->cont = 0;
|
server_socket->cont = 0;
|
||||||
|
@ -1540,7 +1540,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data)
|
||||||
|
|
||||||
if(sock == INVALID_SOCKET)
|
if(sock == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Failed to create server socket: %ld", fluid_socket_get_error());
|
FLUID_LOG(FLUID_ERR, "Failed to create server socket: %d", fluid_socket_get_error());
|
||||||
fluid_socket_cleanup();
|
fluid_socket_cleanup();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1555,7 +1555,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data)
|
||||||
|
|
||||||
if(sock == INVALID_SOCKET)
|
if(sock == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Failed to create server socket: %ld", fluid_socket_get_error());
|
FLUID_LOG(FLUID_ERR, "Failed to create server socket: %d", fluid_socket_get_error());
|
||||||
fluid_socket_cleanup();
|
fluid_socket_cleanup();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1568,7 +1568,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data)
|
||||||
|
|
||||||
if(bind(sock, (const struct sockaddr *) &addr, sizeof(addr)) == SOCKET_ERROR)
|
if(bind(sock, (const struct sockaddr *) &addr, sizeof(addr)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Failed to bind server socket: %ld", fluid_socket_get_error());
|
FLUID_LOG(FLUID_ERR, "Failed to bind server socket: %d", fluid_socket_get_error());
|
||||||
fluid_socket_close(sock);
|
fluid_socket_close(sock);
|
||||||
fluid_socket_cleanup();
|
fluid_socket_cleanup();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1576,7 +1576,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void *data)
|
||||||
|
|
||||||
if(listen(sock, SOMAXCONN) == SOCKET_ERROR)
|
if(listen(sock, SOMAXCONN) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
FLUID_LOG(FLUID_ERR, "Failed to listen on server socket: %ld", fluid_socket_get_error());
|
FLUID_LOG(FLUID_ERR, "Failed to listen on server socket: %d", fluid_socket_get_error());
|
||||||
fluid_socket_close(sock);
|
fluid_socket_close(sock);
|
||||||
fluid_socket_cleanup();
|
fluid_socket_cleanup();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue