From 06b303da88b843ec2787a7fa0e4f5550642379b1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 11 Apr 2011 10:46:25 +0200 Subject: [PATCH] use ATTR_PRINTFALIKE --- src/isync.h | 18 +++++++++--------- src/mdconvert.c | 6 ++++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/isync.h b/src/isync.h index 1886a11..0546ac8 100644 --- a/src/isync.h +++ b/src/isync.h @@ -393,13 +393,13 @@ void cram( const char *challenge, const char *user, const char *pass, extern int DFlags; -void debug( const char *, ... ); -void debugn( const char *, ... ); -void info( const char *, ... ); -void infon( const char *, ... ); -void warn( const char *, ... ); -void error( const char *, ... ); -void sys_error( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) debug( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) debugn( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) info( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) infon( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) warn( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) error( const char *, ... ); +void ATTR_PRINTFLIKE(1, 2) sys_error( const char *, ... ); void flushn( void ); char *next_arg( char ** ); @@ -414,8 +414,8 @@ void *nfcalloc( size_t sz ); void *nfrealloc( void *mem, size_t sz ); char *nfstrdup( const char *str ); int nfvasprintf( char **str, const char *fmt, va_list va ); -int nfasprintf( char **str, const char *fmt, ... ); -int nfsnprintf( char *buf, int blen, const char *fmt, ... ); +int ATTR_PRINTFLIKE(2, 3) nfasprintf( char **str, const char *fmt, ... ); +int ATTR_PRINTFLIKE(3, 4) nfsnprintf( char *buf, int blen, const char *fmt, ... ); void ATTR_NORETURN oob( void ); char *expand_strdup( const char *s ); diff --git a/src/mdconvert.c b/src/mdconvert.c index bd4b7cb..48bd759 100644 --- a/src/mdconvert.c +++ b/src/mdconvert.c @@ -37,8 +37,10 @@ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) # define ATTR_NORETURN __attribute__((noreturn)) +# define ATTR_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else # define ATTR_NORETURN +# define ATTR_PRINTFLIKE(fmt,var) #endif static void ATTR_NORETURN @@ -48,7 +50,7 @@ oob( void ) abort(); } -static void +static void ATTR_PRINTFLIKE(1, 2) sys_error( const char *msg, ... ) { va_list va; @@ -61,7 +63,7 @@ sys_error( const char *msg, ... ) perror( buf ); } -static int +static int ATTR_PRINTFLIKE(3, 4) nfsnprintf( char *buf, int blen, const char *fmt, ... ) { int ret;