From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 8241638582AA for ; Sun, 23 Oct 2022 13:37:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8241638582AA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 1A5B03410C3; Sun, 23 Oct 2022 13:37:12 +0000 (UTC) Date: Sun, 23 Oct 2022 18:07:46 +0545 From: Mike Frysinger To: Tsukasa OI Cc: Andrew Burgess , gdb-patches@sourceware.org Subject: Re: [PATCH 4/4] sim: Suppress non-literal printf warning Message-ID: Mail-Followup-To: Tsukasa OI , Andrew Burgess , gdb-patches@sourceware.org References: <35eaee9855aa3882a1ecc9de9d62c0f8b2fe0e7c.1663073826.git.research_trasio@irq.a4lg.com> <87h70ifq8c.fsf@redhat.com> <22f70b64-0bf9-96f8-a734-d16bbec6504a@irq.a4lg.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="DRJeGg7mm13i4PLE" Content-Disposition: inline In-Reply-To: <22f70b64-0bf9-96f8-a734-d16bbec6504a@irq.a4lg.com> X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --DRJeGg7mm13i4PLE Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 06 Oct 2022 14:39, Tsukasa OI via Gdb-patches wrote: > On 2022/10/05 20:45, Andrew Burgess wrote: > > Tsukasa OI writes: > >> Clang generates a warning if the format parameter of a printf-like fun= ction > >> is not a literal. However, on hw_vabort, it's unavoidable to use non- > >> literal as a format string (unless we make huge redesign). > >> > >> We have "include/diagnostics.h" to suppress certain warnings only when > >> necessary. Because DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL can suppress > >> warnings when the format parameter of a printf-like function is not a > >> literal, this commit adds this (only where necessary) to suppress this > >> error with "-Werror", the default configuration. > >> > >> sim/ChangeLog: > >> > >> * common/sim-hw.c (hw_vabort): Suppress non-literal printf warning > >> by using DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL. > >> --- > >> sim/common/sim-hw.c | 3 +++ > >> 1 file changed, 3 insertions(+) > >> > >> diff --git a/sim/common/sim-hw.c b/sim/common/sim-hw.c > >> index cece5638bc9..36f355d2262 100644 > >> --- a/sim/common/sim-hw.c > >> +++ b/sim/common/sim-hw.c > >> @@ -425,10 +425,13 @@ hw_vabort (struct hw *me, > >> strcat (msg, ": "); > >> strcat (msg, fmt); > >> /* report the problem */ > >> + DIAGNOSTIC_PUSH > >> + DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL > >> sim_engine_vabort (hw_system (me), > >> STATE_HW (hw_system (me))->cpu, > >> STATE_HW (hw_system (me))->cia, > >> msg, ap); > >> + DIAGNOSTIC_POP > >=20 > > Rather than disabling diagnostics, I'd like to propose the patch below > > which expands FMT and AP within sim-hw.c, then passes the expanded > > string through to sim_engine_abort. What do you think of this? >=20 > Ah, It took a while to understand but makes sense to me. >=20 > I just needed to add ATTRIBUTE_PRINTF (2, 0) to suppress "-Werror > -Wformat-nonliteral" but I prefer to use your patch instead. adding ATTRIBUTE_PRINTF doesn't suppress warnings, it fixes them -mike --DRJeGg7mm13i4PLE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmNVMhYACgkQQWM7n+g3 9YGfGw//c9NOJ17KWakyJAMdzKIJv/Ui7Op+noZGuOJoEV31TCi7abcA5HWNqfKH IB+tkB/wSuttrGlLvOlizIHIx0WxV1OuGy5rOteuSGVsceLZ5XOiF2JPkh3faTJL 4YXVsAPvehSrmx3V3hOKVWvVT1ODT8DUrHszYR8j9bhWZ+1HoHYSDPAckUSaStZD mVPHXzdKinxYJRFsRUOL8Ri9KbS9f3KFGqH2JqjR2nJ4AHzVQ9nzqSsQh7cXiswV yOIuuVgp3Cp9fYqYiX/MwoAuNijyw7CNBOHW3VRISaYkGhA0OOJZqd/Hc1qwGJ6D pv0Pv68iTwvia9kF8t3hC0gcVvxJ6cKEK6V2yBrjQrA2Wopxywv6/ZjjRYja2z/R TT1GFEgOxZIclci0YE28QY1vloDdX6uEDKXsCXjaEnuQnZ3iy8IWMNY+uEJGFgxy rIMfLk1SaLXUUeLdqhriL+SohCWhT5D9vvCjSAp/ANr1Y33PUvEwHoZgl4NmW1f7 IQDVXxJWrZmdIASussbrxsXjEwT0psqGKIh7CZj/pAXGOqfxtbzTj+KT/wEd/fdn RU600/WzC7Vi6WlZ/PbeqifSK2Sin8m3fiRMlfRy0la1yRl+iHbGEo1iQjV7sy0S cXVDHnzT4g4GPsIEVpAgsQF6GLKb9sxn7b1PC7CSEYciftxzN0k= =3Woc -----END PGP SIGNATURE----- --DRJeGg7mm13i4PLE--