Re: [PATCH nft 8/8] datatype: suppress "-Wformat-nonliteral" warning in integer_type_print()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux