Re: [PATCH] target: pscsi: avoid Wempty-body warning

From: Willy Tarreau
Date: Mon Mar 22 2021 - 12:27:19 EST


On Mon, Mar 22, 2021 at 05:18:23PM +0100, Arnd Bergmann wrote:
> I agree that this instance of the warning is particularly stupid, but the
> I'd like to leave the warning option there and eventually enable it by
> default because it tends to find other more interesting cases, and this
> one is trivial to work around.
>
> I remember previously fixing a few drivers that did obviously
> incorrect things like
>
> if (error); /* note the extra ';' */
> return error;

I totally agree with this one but usually it's already reported by
another one (probably the one complaining about misindenting). The
case I've seen quite a few times was:

while (condition);

At least I want the ';' on its own line to avoid it being
confused with one that ends a do {} while() block.

> and a lot mostly harmless code like
>
> #ifdef DEBUG_THIS_DRIVER /* always disabled */
> #define dprintk(args...) printk(args)
> #else
> #define dprintk(args...)
> #endif
> /* note the mismatched format string */
> dprintk(KERN_WARNING "error %d\n", &object);
>
> Turning the empty dprintk() into no_printk() means we can catch
> the wrong format string during compile testing.

Hmmm OK for this one. With this said, given how plenty of warnings seem
to consider indent and whatever, I wouldn't be surprised if a difference
is made between a totally empty body and one that results from an empty
macro. But indeed this one can represent a real bug.

Willy