From 71d7d3e6dfd29517268c1848c3348ad0eb7fae13 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sun, 28 Jul 2019 19:52:41 +0200 Subject: [PATCH] add some ATTR_* (mostly) mostly ATTR_PRINTFLIKE(*, 0) for functions with a va_list argument. also, one ATTR_NORETURN and one ATTR_UNUSED, both on functions. also, an explicit suppression for a format string stored in a variable. --- src/common.h | 8 ++++---- src/drv_imap.c | 3 +++ src/main.c | 2 +- src/sync.c | 6 +++--- src/util.c | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/common.h b/src/common.h index b15cc15..1c10459 100644 --- a/src/common.h +++ b/src/common.h @@ -122,8 +122,8 @@ void stats( void ); /* util.c */ -void vdebug( int, const char *, va_list va ); -void vdebugn( int, const char *, va_list va ); +void ATTR_PRINTFLIKE(2, 0) vdebug( int, const char *, va_list va ); +void ATTR_PRINTFLIKE(2, 0) vdebugn( int, const char *, va_list va ); void ATTR_PRINTFLIKE(1, 2) info( const char *, ... ); void ATTR_PRINTFLIKE(1, 2) infon( const char *, ... ); void ATTR_PRINTFLIKE(1, 2) progress( const char *, ... ); @@ -163,7 +163,7 @@ void *nfcalloc( size_t sz ); void *nfrealloc( void *mem, size_t sz ); char *nfstrndup( const char *str, size_t nchars ); char *nfstrdup( const char *str ); -int nfvasprintf( char **str, const char *fmt, va_list va ); +int ATTR_PRINTFLIKE(2, 0) nfvasprintf( char **str, const char *fmt, va_list va ); 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 ); @@ -244,7 +244,7 @@ typedef struct { void init_wakeup( wakeup_t *tmr, void (*cb)( void * ), void *aux ); void conf_wakeup( wakeup_t *tmr, int timeout ); void wipe_wakeup( wakeup_t *tmr ); -static INLINE int pending_wakeup( wakeup_t *tmr ) { return tmr->links.next != 0; } +static INLINE int ATTR_UNUSED pending_wakeup( wakeup_t *tmr ) { return tmr->links.next != 0; } void main_loop( void ); diff --git a/src/drv_imap.c b/src/drv_imap.c index 8137edd..dc00a14 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -306,8 +306,11 @@ send_imap_cmd( imap_store_t *ctx, imap_cmd_t *cmd ) buffmt = "%d %s{%d+}\r\n"; litplus = 1; } +DIAG_PUSH +DIAG_DISABLE("-Wformat-nonliteral") bufl = nfsnprintf( buf, sizeof(buf), buffmt, cmd->tag, cmd->cmd, cmd->param.data_len ); +DIAG_POP if (DFlags & DEBUG_NET) { if (ctx->num_in_progress) printf( "(%d in progress) ", ctx->num_in_progress ); diff --git a/src/main.c b/src/main.c index 2b761c7..2cb092c 100644 --- a/src/main.c +++ b/src/main.c @@ -136,7 +136,7 @@ debug( const char *msg, ... ) } #ifdef __linux__ -static void +static void ATTR_NORETURN crashHandler( int n ) { int dpid; diff --git a/src/sync.c b/src/sync.c index 6b90ba1..786ca1e 100644 --- a/src/sync.c +++ b/src/sync.c @@ -74,7 +74,7 @@ Fclose( FILE *f, int safe ) } } -void +void ATTR_PRINTFLIKE(2, 0) vFprintf( FILE *f, const char *msg, va_list va ) { int r; @@ -86,7 +86,7 @@ vFprintf( FILE *f, const char *msg, va_list va ) } } -void +void ATTR_PRINTFLIKE(2, 3) Fprintf( FILE *f, const char *msg, ... ) { va_list va; @@ -217,7 +217,7 @@ static int check_cancel( sync_vars_t *svars ); #define ST_SENDING_NEW (1<<15) -void +void ATTR_PRINTFLIKE(2, 3) jFprintf( sync_vars_t *svars, const char *msg, ... ) { va_list va; diff --git a/src/util.c b/src/util.c index d506273..878ee40 100644 --- a/src/util.c +++ b/src/util.c @@ -42,7 +42,7 @@ flushn( void ) } } -static void +static void ATTR_PRINTFLIKE(1, 0) printn( const char *msg, va_list va ) { if (*msg == '\v')