Re: [PATCH] kgdb: fix gcc-11 warning on indentation

From: Arnd Bergmann
Date: Mon Mar 22 2021 - 16:27:39 EST


On Mon, Mar 22, 2021 at 9:14 PM Jason Wessel <jason.wessel@xxxxxxxxxxxxx> wrote:
>
> The original board this was developed with was a 32bit eeepc.
>
> The intent was that when v2printk() was called for a verbose > 1
> condition the touch_nmi_watchdog() was called. The test case
> where a whole lot of single steps are executed sequentially was not
> letting the watchdog get reset by the normal kernel routine.
> The serial port was so slow it was pretty easy to hit this problem
> and it would just power cycle itself.
>
> The original intent would have bee:
>
> #define v2printk(a...) do { \
> if (verbose > 1) { \
> printk(KERN_INFO a); \
> touch_nmi_watchdog(); \
> } \
> } while (0)

Ok, thanks for sharing how the code was intended to work. I'll let
you all come up with a decision on what should be done about it
now, I'm happy to send one or two patches to address both the
compiler warning, and the original mistake.

My feeling is it would be best to address the warning first,
pretty much with the patch I sent here, and to change the
behavior as a second patch.

That way the gcc-11 warning can be silenced in stable kernels by
backporting the first patch, while the second patch can be tried
out in new kernels first and might not get backported because the
existing behavior is not harmful.

> I'd guess this probably not the first time gcc-11 is finding brace
> imbalances.

There were only a handful of new -Wmisleading-indentation warnings
for gcc-11, the older compilers already caught every instance in normal
functions, while gcc-11 improved on finding them in macros as well.

Arnd