Skip to content

Commit

Permalink
main: Annotate format string args on new *_utf8 functions
Browse files Browse the repository at this point in the history
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@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
cernekee authored and David Woodhouse committed Dec 7, 2014
1 parent 4efb7c8 commit 50900dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.c
Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 50900dd

Please sign in to comment.