Re: format string is not a string literal

Andrew Pinski
2015-02-24T18:04:15Z

On Tue, Feb 24, 2015 at 9:13 AM, Jack Howarth
<howarth.mailing.lists@gmail.com> wrote:
> Building gdb 7.9 on x86_64-apple-darwin14 produces a number of
> warnings from -Wformat-nonliteral...
>
> darwin-nat.c:184:23: warning: format string is not a string literal
> [-Wformat-nonliteral]
> vprintf_unfiltered (fmt, ap);
> ^~~

Looks like a clang bug because vprintf takes a format and an va_arg
type which means there is no way to tell what the format is going to
look into.
Looks like all are the same clang bug.
Please file a bug with Apple and/or LLVM about this bring broken.

>
> remote.c:6986:37: warning: format string is not a string literal
> [-Wformat-nonliteral]
> if (vsnprintf (rs->buf, max_size, format, ap) >= max_size)
> ^~~~~~
> /usr/include/secure/_stdio.h:75:63: note: expanded from macro 'vsnprintf'
> __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
> ^

See how they even warn about their own header too.

Thanks,
Andrew

> ctf.c:109:39: warning: format string is not a string literal
> [-Wformat-nonliteral]
> if (vfprintf (handler->metadata_fd, format, args) < 0)
> ^~~~~~
>
> ./guile/scm-string.c:70:25: warning: format string is not a string
> literal [-Wformat-nonliteral]
> string = xstrvprintf (format, args);
> ^~~~~~
>
> ./guile/scm-utils.c:86:25: warning: format string is not a string
> literal [-Wformat-nonliteral]
> string = xstrvprintf (format, args);
> ^~~~~~
>
> auto-load.c:486:40: warning: format string is not a string literal
> [-Wformat-nonliteral]
> vfprintf_unfiltered (gdb_stdlog, debug_fmt, debug_args);
> ^~~~~~~~~
>
> complaints.c:188:10: warning: format string is not a string literal
> [-Wformat-nonliteral]
> complaint->fmt, args);
> ^~~~~~~~~~~~~~
> complaints.c:195:12: warning: format string is not a string literal
> [-Wformat-nonliteral]
> vwarning (complaint->fmt, args);
> ^~~~~~~~~~~~~~
> complaints.c:200:23: warning: format string is not a string literal
> [-Wformat-nonliteral]
> msg = xstrvprintf (complaint->fmt, args);
> ^~~~~~~~~~~~~~
>
> ./compile/compile-object-load.c:235:22: warning: format string is not
> a string literal [-Wformat-nonliteral]
> str = xstrvprintf (fmt, ap);
> ^~~
> ./compile/compile-loc2c.c:453:30: warning: format string is not a
> string literal [-Wformat-nonliteral]
> vfprintf_filtered (stream, format, args);
> ^~~~~~
> ./compile/compile-loc2c.c:470:30: warning: format string is not a
> string literal [-Wformat-nonliteral]
> vfprintf_filtered (stream, format, args);
> ^~~~~~
> ./compile/compile-loc2c.c:485:30: warning: format string is not a
> string literal [-Wformat-nonliteral]
> vfprintf_filtered (stream, format, args);
> ^~~~~~