[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmyXX=P4k_ymT=3EmzEuTZryozOTbe=F08bokw=axieUQ@mail.gmail.com>
Date: Thu, 30 Jun 2022 10:31:34 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Justin Stitt <justinstitt@...gle.com>
Cc: Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Nathan Chancellor <nathan@...nel.org>,
Tom Rix <trix@...hat.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
llvm@...ts.linux.dev, Andy Shevchenko <andy.shevchenko@...il.com>
Subject: Re: [PATCH] lib/test_printf.c: fix clang -Wformat warnings
On Thu, Jun 30, 2022 at 1:14 AM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Thu, Jun 30, 2022 at 2:11 AM Justin Stitt <justinstitt@...gle.com> wrote:
> >
> > + /* disable -Wformat for this chunk */
> > + NOWARN(-Wformat,
> > test("0|1|1|128|255", "%hhu|%hhu|%hhu|%hhu|%hhu", 0, 1, 257, 128, -1);
> > test("0|1|1|-128|-1", "%hhd|%hhd|%hhd|%hhd|%hhd", 0, 1, 257, 128, -1);
> > test("2015122420151225", "%ho%ho%#ho", 1037, 5282, -11627);
>
> Perhaps shift right the lines as well?
Along these lines, I think it would look nicer to pass a block
statement (a group of statements) to the macro rather than use
__VA_ARGS__. Here's an example:
https://godbolt.org/z/fsYcGGEMb
You have to be careful with control flow out of blocks like this
sometimes, but for these simple localized cases it looks like that
should be fine.
As Nathan mentions, you can probably re-use the existing infra in your
definition of NOWARN. I do prefer some macro to make it appear that
the pragma is scoped to a block statement, rather than multiple lines
for the diag push + pop inline.
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists