lkml.org 
[lkml]   [2022]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] lib/test_printf.c: fix clang -Wformat warnings
On Thu, Jun 30, 2022 at 1:14 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Thu, Jun 30, 2022 at 2:11 AM Justin Stitt <justinstitt@google.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

\
 
 \ /
  Last update: 2022-06-30 19:33    [W:0.123 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site