[PATCH 3/3] main: Annotate format string args on new *_utf8 functions
Kevin Cernekee
cernekee at gmail.com
Sat Dec 6 23:01:21 PST 2014
The new charset translation functions need to use caller-supplied format
strings; this change corrects the following warnings:
CC openconnect-main.o
main.c:422:22: warning: format string is not a string literal
[-Wformat-nonliteral]
return vfprintf(f, fmt, args);
^~~
main.c:424:29: warning: format string is not a string literal
[-Wformat-nonliteral]
ret = vasprintf(&utf8_str, fmt, args);
^~~
Signed-off-by: Kevin Cernekee <cernekee at gmail.com>
---
main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/main.c b/main.c
index b971dbf..6415f2e 100644
--- a/main.c
+++ b/main.c
@@ -258,7 +258,8 @@ static struct option long_options[] = {
};
#ifdef _WIN32
-static int vfprintf_utf8(FILE *f, const char *fmt, va_list args)
+static int __attribute__ ((format(printf, 2, 0)))
+ vfprintf_utf8(FILE *f, const char *fmt, va_list args)
{
HANDLE h = GetStdHandle(f == stdout ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
wchar_t wbuf[1024];
@@ -273,7 +274,8 @@ static int vfprintf_utf8(FILE *f, const char *fmt, va_list args)
return chars;
}
-static int fprintf_utf8(FILE *f, const char *fmt, ...)
+static int __attribute__ ((format(printf, 2, 3)))
+ fprintf_utf8(FILE *f, const char *fmt, ...)
{
va_list args;
int ret;
@@ -408,7 +410,8 @@ static int is_ascii(char *str)
return 1;
}
-static int vfprintf_utf8(FILE *f, const char *fmt, va_list args)
+static int __attribute__ ((format(printf, 2, 0)))
+ vfprintf_utf8(FILE *f, const char *fmt, va_list args)
{
char *utf8_str;
iconv_t ic;
@@ -463,7 +466,8 @@ static int vfprintf_utf8(FILE *f, const char *fmt, va_list args)
return ret;
}
-static int fprintf_utf8(FILE *f, const char *fmt, ...)
+static int __attribute__ ((format(printf, 2, 3)))
+ fprintf_utf8(FILE *f, const char *fmt, ...)
{
va_list args;
int ret;
--
2.1.1
More information about the openconnect-devel
mailing list