linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Joe Thornber <ejt@redhat.com>,
	linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	dm-devel@redhat.com, Mikulas Patocka <mpatocka@redhat.com>,
	Shaohua Li <shli@kernel.org>, Alasdair Kergon <agk@redhat.com>
Subject: Re: dm block manager: use do/while(0) for empty macros
Date: Tue, 25 Oct 2016 14:20:30 -0400	[thread overview]
Message-ID: <20161025182030.GA4879@redhat.com> (raw)
In-Reply-To: <20161025155434.21727-1-arnd@arndb.de>

On Tue, Oct 25 2016 at 11:54am -0400,
Arnd Bergmann <arnd@arndb.de> wrote:

> make W=1 reports a new warning for the dm-block-manager:
> 
> drivers/md/persistent-data/dm-block-manager.c: In function ‘dm_bm_unlock’:
> drivers/md/persistent-data/dm-block-manager.c:598:3: error: suggest braces around empty body in an ‘else’ statement [-Werror=empty-body]
> 
> This is completely harmless, but generally speaking it's a good idea to
> address this warning as it can often detect nasty bugs, and replacing
> empty macros with "do { } while (0)" is generally considered good style
> to make code more robust anyway.
> 
> Fixes: f94bdb2e26b6 ("dm block manager: make block locking optional")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks Arnd, I'll fold this in.  I suspected this was the right thing to
do.  Strange that my build didn't say anything through, I used:
make C=1 CF=-D__CHECK_ENDIAN__ M=drivers/md

I'll be sure to use make W=1 in the future.

> ---
>  drivers/md/persistent-data/dm-block-manager.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/md/persistent-data/dm-block-manager.c b/drivers/md/persistent-data/dm-block-manager.c
> index b619c383d88d..a6dde7cab458 100644
> --- a/drivers/md/persistent-data/dm-block-manager.c
> +++ b/drivers/md/persistent-data/dm-block-manager.c
> @@ -306,13 +306,13 @@ static void report_recursive_bug(dm_block_t b, int r)
>  
>  #else  /* !CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING */
>  
> -#define bl_init(x)
> +#define bl_init(x) do { } while (0)
>  #define bl_down_read(x) 0
>  #define bl_down_read_nonblock(x) 0
> -#define bl_up_read(x)
> +#define bl_up_read(x) do { } while (0)
>  #define bl_down_write(x) 0
> -#define bl_up_write(x)
> -#define report_recursive_bug(x, y)
> +#define bl_up_write(x) do { } while (0)
> +#define report_recursive_bug(x, y) do { } while (0)
>  
>  #endif /* CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING */
>  
> -- 
> 2.9.0
> 
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel

      reply	other threads:[~2016-10-25 18:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25 15:54 [PATCH] dm block manager: use do/while(0) for empty macros Arnd Bergmann
2016-10-25 18:20 ` Mike Snitzer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161025182030.GA4879@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=arnd@arndb.de \
    --cc=dm-devel@redhat.com \
    --cc=ejt@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=shli@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).