From patchwork Fri Oct 11 20:54:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 34926 Received: (qmail 20961 invoked by alias); 11 Oct 2019 20:54:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20952 invoked by uid 89); 11 Oct 2019 20:54:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=silence, HX-HELO:sk:mail.ef, HX-Spam-Relays-External:sk:mail.ef, H*RU:sk:mail.ef X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.142.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Oct 2019 20:54:44 +0000 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 69F7E340171 for ; Fri, 11 Oct 2019 16:54:42 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 0cXXXSyMlbyD; Fri, 11 Oct 2019 16:54:42 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 21261340169; Fri, 11 Oct 2019 16:54:42 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 21261340169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1570827282; bh=nwLwxxH9E9LGvdkAcPtM5vAwwYnXNyeuTa/mS0v9nWA=; h=From:To:Date:Message-Id:MIME-Version; b=rN01JEiyV2gl7Dk/tN73ldXkwu4i+w6PQsSEt+JqzK7lQ18blGYgok18EbhUtViIx HUB6IJDZ7TV9Caip1/u1i28mhIMbKoKaY92SUxz+uPwZHYaTY5fUmbFkjQl1gSZVOy uGg/EqNwU+uo4upLo8WJuhqlwReHWcDGFUV5DRrK5mkLc60DcR8FZfu9SvC7o/40dR RYL6BgfiFfO80RNP6GOL0JOTleUa+hFEFoTQpnc9KCG6eA+mUuaRvKdc68dfv28E9m 822nn7+r08sHK0Mqw75Bp3FayzIs9zTikVJhwESUMsk6bS/vaN0tsWofBEZkjWydvV 4g/CJCUSSP8Fw== Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id fa2dB8YUUxo1; Fri, 11 Oct 2019 16:54:42 -0400 (EDT) Received: from smarchi-efficios.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id 003BE34015E; Fri, 11 Oct 2019 16:54:41 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: Silence -Wformat-nonliteral warning with clang Date: Fri, 11 Oct 2019 16:54:26 -0400 Message-Id: <20191011205426.1859-1-simon.marchi@efficios.com> MIME-Version: 1.0 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. Change-Id: I58ad41793448f38835c5d6ba7b9e5c4dd8df260f --- gdb/ui-out.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdb/ui-out.c b/gdb/ui-out.c index a64c79481cad..6b0b5acd3e13 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -26,6 +26,7 @@ #include "ui-out.h" #include "gdbsupport/format.h" #include "cli/cli-style.h" +#include "diagnostics.h" #include #include @@ -587,7 +588,15 @@ ui_out::call_do_message (const ui_file_style &style, const char *format, va_list args; va_start (args, format); + + /* Since call_do_message is only used as a helper of vmessage, silence the + warning here once instead of at all call sites in vmessage, if we were + to put a "format" attribute on call_do_message. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL do_message (style, format, args); + DIAGNOSTIC_POP + va_end (args); }