From ef170dda7fbab53682c9bc287dec93fa86130bc9 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sun, 9 Sep 2018 21:49:59 -0700 Subject: [PATCH] add a formatting attribute check Tell Clang that parameter is a printf style format using the attribute flag This helps in avoiding below warnings seen with clang unarr.c:106:22: error: format string is not a string literal [-Werror,-Wformat-nonliteral] | vfprintf(stderr, msg, args); | ^~~ Upstream-Status: Pending Signed-off-by: Khem Raj --- cut-n-paste/unarr/common/unarr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/cut-n-paste/unarr/common/unarr.c +++ b/cut-n-paste/unarr/common/unarr.c @@ -92,7 +92,7 @@ size_t ar_get_global_comment(ar_archive return ar->get_comment(ar, buffer, count); } -void ar_log(const char *prefix, const char *file, int line, const char *msg, ...) +void __attribute__((__format__ (__printf__, 4, 5))) ar_log(const char *prefix, const char *file, int line, const char *msg, ...) { va_list args; va_start(args, msg); --- a/cut-n-paste/synctex/synctex_parser_utils.c +++ b/cut-n-paste/synctex/synctex_parser_utils.c @@ -87,11 +87,11 @@ void _synctex_free(void * ptr) { # include #endif -int _synctex_error(const char * reason, ...) __attribute__((__format__ (__printf__, 1, 2))); -int _synctex_log(int level, const char * prompt, const char * reason, va_list arg) __attribute__((__format__ (__printf__, 3, 0))); - -int _synctex_log(int level, const char * prompt, const char * reason,va_list arg) { +static int _synctex_log(int level, const char * prompt, const char * reason, ...) SYNCTEX_PRINTF_FORMAT(3, 0); +static int _synctex_log(int level, const char * prompt, const char * reason, ...) { + va_list arg; int result; + va_start(arg, reason); # ifdef SYNCTEX_RECENT_WINDOWS {/* This code is contributed by William Blum. As it does not work on some older computers, @@ -133,10 +133,10 @@ int _synctex_log(int level, const char * result += vfprintf(where, reason, arg); result += fprintf(where,"\n"); # endif + va_end(arg); return result; } -__attribute__((__format__ (__printf__, 1, 0))) int _synctex_error(const char * reason,...) { va_list arg; int result; @@ -355,6 +355,7 @@ char * _synctex_merge_strings(const char size_t len = strlen(temp); if(UINT_MAX-len