netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Haller <thaller@redhat.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft 8/8] datatype: suppress "-Wformat-nonliteral" warning in integer_type_print()
Date: Mon, 28 Aug 2023 18:24:25 +0200	[thread overview]
Message-ID: <272f8c10d8e7ac9265c4af23e8d7ae3860438266.camel@redhat.com> (raw)
In-Reply-To: <ZOzDNFqXdftWgtTF@calendula>

On Mon, 2023-08-28 at 17:54 +0200, Pablo Neira Ayuso wrote:
> On Mon, Aug 28, 2023 at 05:33:01PM +0200, Thomas Haller wrote:
> > On Mon, 2023-08-28 at 17:08 +0200, Pablo Neira Ayuso wrote:
> > > On Mon, Aug 28, 2023 at 04:43:58PM +0200, Thomas Haller wrote:
> > > > 
> > > > +       _NFT_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral")
> > > 
> > > Maybe simply -Wno-format-nonliteral turn off in Clang so there is
> > > no
> > > need for this PRAGMA in order to simplify things.
> > 
> > "-Wformat-nonliteral" seems a useful warning. I would rather not
> > disable it at a larger scale.
> > 
> > Gcc also supports "-Wformat-nonliteral" warning, but for some
> > reason it
> > does not warn here (also not, when I pass "-Wformat=2"). I don't
> > understand why that is.
> 
> Can you see any other way to fix this clang compilation eror without
> this pragma? What makes clang unhappy with this code?
> 


the compiler warning happens, because the argument isn't a string
literal. But the deeper cause is something else entirely (and the
patches wrong).


Those "%Zu" format strings aren't intended for libc's printf. Instead,
it's intended for gmp_vfprintf(), which implements a different meaning
for "Z".

The patch "src: use "%zx" format instead of "%Zx"" should be dropped.
Likewise, "datatype: suppress "-Wformat-nonliteral" warning in
integer_type_print()".


Instead, the format attribute from

int nft_gmp_print(struct output_ctx *octx, const char *fmt, ...)
       __attribute__((format(printf, 2, 0)));

needs to be dropped. This is not the "printf" format.


Will do in v2.


Thomas


      reply	other threads:[~2023-08-28 16:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 14:43 [PATCH nft 0/8] fix compiler warnings with clang Thomas Haller
2023-08-28 14:43 ` [PATCH nft 1/8] netlink: avoid "-Wenum-conversion" warning in dtype_map_from_kernel() Thomas Haller
2023-08-28 14:43 ` [PATCH nft 2/8] netlink: avoid "-Wenum-conversion" warning in parser_bison.y Thomas Haller
2023-08-28 14:43 ` [PATCH nft 3/8] src: use "%zx" format instead of "%Zx" Thomas Haller
2023-08-28 14:43 ` [PATCH nft 4/8] datatype: avoid cast-align warning with struct sockaddr result from getaddrinfo() Thomas Haller
2023-08-28 14:43 ` [PATCH nft 5/8] src: rework SNPRINTF_BUFFER_SIZE() and avoid "-Wunused-but-set-variable" Thomas Haller
2023-08-28 15:13   ` Pablo Neira Ayuso
2023-08-28 15:49     ` Thomas Haller
2023-08-28 16:04       ` Pablo Neira Ayuso
2023-08-28 16:45         ` Thomas Haller
2023-08-28 19:53           ` Pablo Neira Ayuso
2023-08-29 13:01             ` Thomas Haller
2023-08-28 14:43 ` [PATCH nft 6/8] src: suppress "-Wunused-but-set-variable" warning with "parser_bison.c" Thomas Haller
2023-08-28 14:43 ` [PATCH nft 7/8] utils: add _NFT_PRAGMA_WARNING_DISABLE()/_NFT_PRAGMA_WARNING_REENABLE helpers Thomas Haller
2023-08-28 14:43 ` [PATCH nft 8/8] datatype: suppress "-Wformat-nonliteral" warning in integer_type_print() Thomas Haller
2023-08-28 15:08   ` Pablo Neira Ayuso
2023-08-28 15:33     ` Thomas Haller
2023-08-28 15:54       ` Pablo Neira Ayuso
2023-08-28 16:24         ` Thomas Haller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=272f8c10d8e7ac9265c4af23e8d7ae3860438266.camel@redhat.com \
    --to=thaller@redhat.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).