lkml.org 
[lkml]   [2020]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC PATCH 1/9] kernel.h: add do_empty() macro
From
Date
On 4/18/20 11:41 AM, Randy Dunlap wrote:
> --- linux-next-20200327.orig/include/linux/kernel.h
> +++ linux-next-20200327/include/linux/kernel.h
> @@ -40,6 +40,14 @@
> #define READ 0
> #define WRITE 1
>
> +/*
> + * When using -Wextra, an "if" statement followed by an empty block
> + * (containing only a ';'), produces a warning from gcc:
> + * warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
> + * Replace the empty body with do_empty() to silence this warning.
> + */
> +#define do_empty() do { } while (0)
> +
> /**
> * ARRAY_SIZE - get the number of elements in array @arr
> * @arr: array to be sized

I'm less than enthusiast about introducing a new macro to suppress
"empty body" warnings. Anyone who encounters code in which this macro is
used will have to look up the definition of this macro to learn what it
does. Has it been considered to suppress empty body warnings by changing
the empty bodies from ";" into "{}"?

Thanks,

Bart.

\
 
 \ /
  Last update: 2020-04-19 00:21    [W:1.611 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site