(From Oliver Stoneberg)

This is an updated version of my earlier ATTR_PRINTF patch. It was 
reviewed by Atari Ace to use ATTR_PRINTF properly and fixes even more 
format errors. I also reviewed the whole source again and it is now 
used in all possible places.
This commit is contained in:
Aaron Giles 2008-01-03 05:37:18 +00:00
parent 25eee632f6
commit 422ccce762
28 changed files with 45 additions and 45 deletions

View File

@ -1153,7 +1153,7 @@ static const M68HC11_OPCODE opcode_table_page4[256] =
static char *output;
static const UINT8 *rombase;
static void print(const char *fmt, ...)
static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
{
va_list vl;

View File

@ -129,7 +129,7 @@ static const UINT32 mips_mtc0_writemask[]=
};
#if 0
void GTELOG(const char *a,...)
void ATTR_PRINTF(1,2) GTELOG(const char *a,...)
{
va_list va;
char s_text[ 1024 ];
@ -139,7 +139,7 @@ void GTELOG(const char *a,...)
logerror( "%08x: GTE: %08x %s\n", mipscpu.pc, INS_COFUN( mipscpu.op ), s_text );
}
#else
INLINE void GTELOG(const char *a, ...) {}
INLINE void ATTR_PRINTF(1,2) GTELOG(const char *a, ...) {}
#endif
static UINT32 getcp2dr( int n_reg );

View File

@ -66,7 +66,7 @@ INLINE char *signed_imm16(UINT32 op)
static char *output;
static void print(const char *fmt, ...)
static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
{
va_list vl;

View File

@ -28,7 +28,7 @@ static int dasm_table_built = 0;
static char *output;
static void print(const char *fmt, ...)
static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
{
va_list vl;

View File

@ -59,7 +59,7 @@ static offs_t pcbase;
static char *output;
static void print(const char *fmt, ...)
static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
{
va_list vl;

View File

@ -38,7 +38,7 @@ x86log_context *x86log_create_context(const char *filename);
void x86log_free_context(x86log_context *log);
/* add a comment associated with a given code pointer */
void x86log_add_comment(x86log_context *log, x86code *base, const char *format, ...);
void x86log_add_comment(x86log_context *log, x86code *base, const char *format, ...) ATTR_PRINTF(3, 4);
/* mark a given range as data for logging purposes */
void x86log_mark_as_data(x86log_context *log, x86code *base, x86code *end, int size);
@ -47,7 +47,7 @@ void x86log_mark_as_data(x86log_context *log, x86code *base, x86code *end, int s
void x86log_disasm_code_range(x86log_context *log, const char *label, x86code *start, x86code *stop);
/* manually printf information to the log file */
void x86log_printf(x86log_context *log, const char *format, ...);
void x86log_printf(x86log_context *log, const char *format, ...) ATTR_PRINTF(2, 3);
#endif /* __X86LOG_H__ */

View File

@ -177,7 +177,7 @@ void debug_halt_on_next_instruction(void);
void debug_refresh_display(void);
int debug_get_execution_state(void);
UINT32 debug_get_execution_counter(void);
void debug_trace_printf(int cpunum, const char *fmt, ...);
void debug_trace_printf(int cpunum, const char *fmt, ...) ATTR_PRINTF(2,3);
void debug_source_script(const char *file);
void debug_flush_traces(void);

View File

@ -141,7 +141,7 @@ UINT32 mame_fwrite(mame_file *file, const void *buffer, UINT32 length);
int mame_fputs(mame_file *f, const char *s);
/* printf-style text write to a file */
int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...);
int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...) ATTR_PRINTF(2,3);

View File

@ -11,7 +11,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{
@ -68,7 +68,7 @@ void adc083x_init( int chip, int type, double (*input_callback)(int input) )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_init( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_init( %d ) chip out of range\n", chip );
return;
}
@ -134,7 +134,7 @@ void adc083x_cs_write( int chip, int cs )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_cs_write( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_cs_write( %d ) chip out of range\n", chip );
return;
}
@ -254,7 +254,7 @@ void adc083x_clk_write( int chip, int clk )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_clk_write( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_clk_write( %d ) chip out of range\n", chip );
return;
}
@ -398,7 +398,7 @@ void adc083x_di_write( int chip, int di )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_di_write( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_di_write( %d ) chip out of range\n", chip );
return;
}
@ -418,7 +418,7 @@ void adc083x_se_write( int chip, int se )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_se_write( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_se_write( %d ) chip out of range\n", chip );
return;
}
@ -438,7 +438,7 @@ int adc083x_sars_read( int chip )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_sars_read( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_sars_read( %d ) chip out of range\n", chip );
return 0;
}
@ -454,7 +454,7 @@ int adc083x_do_read( int chip )
if( chip >= MAX_ADC083X_CHIPS )
{
verboselog( 0, "adc083x_do_read( %d ) chip %d out of range\n", chip );
verboselog( 0, "adc083x_do_read( %d ) chip out of range\n", chip );
return 0;
}

View File

@ -13,7 +13,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -25,7 +25,7 @@ Up to 4096 bytes can be addressed.
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -16,7 +16,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -14,7 +14,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -162,7 +162,7 @@ const rom_entry *rom_next_chunk(const rom_entry *romp)
debugload - log data to a file
-------------------------------------------------*/
static void CLIB_DECL debugload(const char *string, ...)
static void CLIB_DECL ATTR_PRINTF(1,2) debugload(const char *string, ...)
{
#ifdef LOG_LOAD
static int opened;

View File

@ -123,7 +123,7 @@ static void discrete_reset(void *chip);
*
*************************************/
static void CLIB_DECL discrete_log(const char *text, ...)
static void CLIB_DECL ATTR_PRINTF(1,2) discrete_log(const char *text, ...)
{
if (DISCRETE_DEBUGLOG)
{

View File

@ -16,7 +16,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -206,7 +206,7 @@ static int select_game_handle_key(input_code keycode, char value);
to the string pool
-------------------------------------------------*/
INLINE const char *CLIB_DECL menu_string_pool_add(const char *format, ...)
INLINE const char *CLIB_DECL ATTR_PRINTF(1,2) menu_string_pool_add(const char *format, ...)
{
char *result = &menu_string_pool[menu_string_pool_offset];
va_list arg;

View File

@ -70,7 +70,7 @@ astring *astring_inssubstr(astring *dst, int insbefore, const astring *src, int
astring *astring_substr(astring *str, int start, int count);
/* formatted printf to an astring */
int astring_printf(astring *dst, const char *format, ...);
int astring_printf(astring *dst, const char *format, ...) ATTR_PRINTF(2,3);

View File

@ -100,7 +100,7 @@ int core_fputs(core_file *f, const char *s);
/* printf-style text write to a file */
int core_vfprintf(core_file *f, const char *fmt, va_list va);
int CLIB_DECL core_fprintf(core_file *f, const char *fmt, ...);
int CLIB_DECL core_fprintf(core_file *f, const char *fmt, ...) ATTR_PRINTF(2,3);

View File

@ -100,9 +100,9 @@ static options_data *find_entry_data(core_options *opts, const char *string, int
static void update_data(core_options *opts, options_data *data, const char *newdata, int priority);
static int parse_option_name(core_options *opts, const char *srcstring, options_data *data);
static void message(core_options *opts, options_message msgtype, const char *format, ...);
static void message(core_options *opts, options_message msgtype, const char *format, ...) ATTR_PRINTF(3,4);
static UINT32 hash_value(core_options *opts, const char *str);
static void output_printf(void (*output)(const char *s), const char *format, ...);
static void output_printf(void (*output)(const char *s), const char *format, ...) ATTR_PRINTF(2,3);

View File

@ -88,7 +88,7 @@ struct _object_pool_iterator
***************************************************************************/
static void memory_destruct(void *object, size_t size);
static void report_failure(object_pool *pool, const char *format, ...);
static void report_failure(object_pool *pool, const char *format, ...) ATTR_PRINTF(2,3);
@ -268,7 +268,7 @@ void *pool_object_add_file_line(object_pool *pool, object_type _type, void *obje
/* if we have an invalid type, fail */
if (type == NULL)
{
report_failure(pool, "pool_object_add (via %s:%d): Attempted to add object of unknown type", file, line, (int)size);
report_failure(pool, "pool_object_add (via %s:%d): Attempted to add object of unknown type with size %d", file, line, (int)size);
return object;
}

View File

@ -222,7 +222,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{
@ -289,7 +289,7 @@ static WRITE32_HANDLER( mb89371_w )
static READ32_HANDLER( mb89371_r )
{
UINT32 data = 0xffffffff;
verboselog( 2, "mb89371_r %08x %08x\n", offset, mem_mask, data );
verboselog( 2, "mb89371_r %08x %08x %08x\n", offset, mem_mask, data );
return data;
}
@ -2002,13 +2002,13 @@ static READ32_HANDLER( gtrfrks_io_r )
break;
}
verboselog( 2, "gtrfrks_io_r( %08x, %08x ) %08x\n", data );
verboselog( 2, "gtrfrks_io_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
return data;
}
static WRITE32_HANDLER( gtrfrks_io_w )
{
verboselog( 2, "gtrfrks_io_w( %08x, %08x ) %08x\n", data );
verboselog( 2, "gtrfrks_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
switch( offset )
{
@ -2621,7 +2621,7 @@ static void dmx_output_callback( int offset, int data )
static WRITE32_HANDLER( dmx_io_w )
{
verboselog( 2, "dmx_io_w( %08x, %08x ) %08x\n", data );
verboselog( 2, "dmx_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
switch( offset )
{

View File

@ -273,7 +273,7 @@ Notes:
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -931,7 +931,7 @@ Notes:
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -26,7 +26,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{

View File

@ -13,7 +13,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{
@ -726,7 +726,7 @@ static void sio_timer_adjust( int n_port )
if( m_p_n_sio_baud[ n_port ] != 0 && n_prescaler != 0 )
{
n_time = attotime_mul(ATTOTIME_IN_HZ(33868800), n_prescaler * m_p_n_sio_baud[n_port]);
verboselog( 2, "sio_timer_adjust( %d ) = %f ( %d x %d )\n", n_port, n_time, n_prescaler, m_p_n_sio_baud[ n_port ] );
verboselog( 2, "sio_timer_adjust( %d ) = %s ( %d x %d )\n", n_port, attotime_string(n_time, 9), n_prescaler, m_p_n_sio_baud[ n_port ] );
}
else
{

View File

@ -12,7 +12,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{
@ -532,7 +532,7 @@ void zs01_scl_write( int chip, int scl )
memset( &c->read_buffer[ 0 ], 0xff, 2 );
}
verboselog( 1, "zs01(%d) <- status: %02x%02\n", chip,
verboselog( 1, "zs01(%d) <- status: %02x%02x\n", chip,
c->read_buffer[ 0 ], c->read_buffer[ 1 ] );
verboselog( 1, "zs01(%d) <- data: %02x%02x%02x%02x%02x%02x%02x%02x\n", chip,

View File

@ -25,7 +25,7 @@
#define VERBOSE_LEVEL ( 0 )
INLINE void verboselog( int n_level, const char *s_fmt, ... )
INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{