This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdb: Silence -Wformat-nonliteral warning with clang
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Simon Marchi <simon dot marchi at efficios dot com>
- Date: Sun, 13 Oct 2019 11:17:14 -0700
- Subject: Re: [PATCH] gdb: Silence -Wformat-nonliteral warning with clang
- References: <20191011205426.1859-1-simon.marchi@efficios.com>
On Fri, 11 Oct 2019 16:54:26 -0400
Simon Marchi <simon.marchi@efficios.com> wrote:
> We get this warning when building with clang:
>
> CXX ui-out.o
> /home/smarchi/src/binutils-gdb/gdb/ui-out.c:590:22: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
> do_message (style, format, args);
> ^~~~~~
>
> This can be considered a legitimate warning, as call_do_message's format
> parameter is not marked as a format string. Therefore, we should
> normally mark the call_do_message method with the `format` attribute.
> However, doing so just moves (and multiplies) the problem, as all the
> uses of call_do_message in the vmessage method now warn. If we wanted
> to continue on that path, we should silence the warning for each of
> them, as a way of telling the compiler "it's ok, we know what we are
> doing".
>
> But since call_do_message is really just vmessage's little helper, it's
> simpler to just silence the warning at that single point.
>
> gdb/ChangeLog:
>
> * ui-out.c (ui_out::call_do_message): Silence
> -Wformat-nonliteral warning.
LGTM.
Kevin