All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info
@ 2020-07-06 14:59 Marcos Paulo de Souza
  2020-07-07  8:34 ` Nikolay Borisov
  2020-07-07 14:23 ` Anand Jain
  0 siblings, 2 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2020-07-06 14:59 UTC (permalink / raw)
  To: dsterba, linux-btrfs; +Cc: Marcos Paulo de Souza

From: Marcos Paulo de Souza <mpdesouza@suse.com>

Without this change it's not possible to use these macros and having an
if-else construction without using braces.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 fs/btrfs/ctree.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a256961c0dbe..cef0489a1523 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1278,18 +1278,18 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
 					 BTRFS_MOUNT_##opt)
 
 #define btrfs_set_and_info(fs_info, opt, fmt, args...)			\
-{									\
+do {									\
 	if (!btrfs_test_opt(fs_info, opt))				\
 		btrfs_info(fs_info, fmt, ##args);			\
 	btrfs_set_opt(fs_info->mount_opt, opt);				\
-}
+} while (0)
 
 #define btrfs_clear_and_info(fs_info, opt, fmt, args...)		\
-{									\
+do {									\
 	if (btrfs_test_opt(fs_info, opt))				\
 		btrfs_info(fs_info, fmt, ##args);			\
 	btrfs_clear_opt(fs_info->mount_opt, opt);			\
-}
+} while (0)
 
 /*
  * Requests for changes that need to be done during transaction commit.
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info
  2020-07-06 14:59 [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info Marcos Paulo de Souza
@ 2020-07-07  8:34 ` Nikolay Borisov
  2020-07-07 13:38   ` Marcos Paulo de Souza
  2020-07-07 14:10   ` David Sterba
  2020-07-07 14:23 ` Anand Jain
  1 sibling, 2 replies; 5+ messages in thread
From: Nikolay Borisov @ 2020-07-07  8:34 UTC (permalink / raw)
  To: Marcos Paulo de Souza, dsterba, linux-btrfs; +Cc: Marcos Paulo de Souza



On 6.07.20 г. 17:59 ч., Marcos Paulo de Souza wrote:
> From: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> Without this change it's not possible to use these macros and having an
> if-else construction without using braces.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

This change would have been better accompanied with another one showing
intended usage. If it's part of a bigger rework then postpone it and
send everything altogether.

> ---
>  fs/btrfs/ctree.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index a256961c0dbe..cef0489a1523 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1278,18 +1278,18 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
>  					 BTRFS_MOUNT_##opt)
>  
>  #define btrfs_set_and_info(fs_info, opt, fmt, args...)			\
> -{									\
> +do {									\
>  	if (!btrfs_test_opt(fs_info, opt))				\
>  		btrfs_info(fs_info, fmt, ##args);			\
>  	btrfs_set_opt(fs_info->mount_opt, opt);				\
> -}
> +} while (0)
>  
>  #define btrfs_clear_and_info(fs_info, opt, fmt, args...)		\
> -{									\
> +do {									\
>  	if (btrfs_test_opt(fs_info, opt))				\
>  		btrfs_info(fs_info, fmt, ##args);			\
>  	btrfs_clear_opt(fs_info->mount_opt, opt);			\
> -}
> +} while (0)
>  
>  /*
>   * Requests for changes that need to be done during transaction commit.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info
  2020-07-07  8:34 ` Nikolay Borisov
@ 2020-07-07 13:38   ` Marcos Paulo de Souza
  2020-07-07 14:10   ` David Sterba
  1 sibling, 0 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2020-07-07 13:38 UTC (permalink / raw)
  To: Nikolay Borisov, dsterba, linux-btrfs; +Cc: Marcos Paulo de Souza

On Tue, 2020-07-07 at 11:34 +0300, Nikolay Borisov wrote:
> 
> On 6.07.20 г. 17:59 ч., Marcos Paulo de Souza wrote:
> > From: Marcos Paulo de Souza <mpdesouza@suse.com>
> > 
> > Without this change it's not possible to use these macros and
> having an
> > if-else construction without using braces.
> > 
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> This change would have been better accompanied with another one
> showing
> intended usage. If it's part of a bigger rework then postpone it and
> send everything altogether.

Yes, this is part of my fscontext btrfs port. Ok, I'll send this again
again along with all the port patches.

Thanks,
  Marcos

> 
> > ---
> >  fs/btrfs/ctree.h | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> > index a256961c0dbe..cef0489a1523 100644
> > --- a/fs/btrfs/ctree.h
> > +++ b/fs/btrfs/ctree.h
> > @@ -1278,18 +1278,18 @@ static inline u32
> BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
> >  					 BTRFS_MOUNT_##opt)
> >  
> >  #define btrfs_set_and_info(fs_info, opt, fmt, args...)		
> 	\
> > -{									
> \
> > +do {								
> 	\
> >  	if (!btrfs_test_opt(fs_info, opt))				
> \
> >  		btrfs_info(fs_info, fmt, ##args);			\
> >  	btrfs_set_opt(fs_info->mount_opt, opt);				
> \
> > -}
> > +} while (0)
> >  
> >  #define btrfs_clear_and_info(fs_info, opt, fmt, args...)		
> \
> > -{									
> \
> > +do {								
> 	\
> >  	if (btrfs_test_opt(fs_info, opt))				\
> >  		btrfs_info(fs_info, fmt, ##args);			\
> >  	btrfs_clear_opt(fs_info->mount_opt, opt);			\
> > -}
> > +} while (0)
> >  
> >  /*
> >   * Requests for changes that need to be done during transaction
> commit.
> > 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info
  2020-07-07  8:34 ` Nikolay Borisov
  2020-07-07 13:38   ` Marcos Paulo de Souza
@ 2020-07-07 14:10   ` David Sterba
  1 sibling, 0 replies; 5+ messages in thread
From: David Sterba @ 2020-07-07 14:10 UTC (permalink / raw)
  To: Nikolay Borisov
  Cc: Marcos Paulo de Souza, dsterba, linux-btrfs, Marcos Paulo de Souza

On Tue, Jul 07, 2020 at 11:34:12AM +0300, Nikolay Borisov wrote:
> 
> 
> On 6.07.20 г. 17:59 ч., Marcos Paulo de Souza wrote:
> > From: Marcos Paulo de Souza <mpdesouza@suse.com>
> > 
> > Without this change it's not possible to use these macros and having an
> > if-else construction without using braces.
> > 
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> This change would have been better accompanied with another one showing
> intended usage. If it's part of a bigger rework then postpone it and
> send everything altogether.

I think the change is good as is, multi-statement macros should always be
enclosed in do {} while(0);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info
  2020-07-06 14:59 [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info Marcos Paulo de Souza
  2020-07-07  8:34 ` Nikolay Borisov
@ 2020-07-07 14:23 ` Anand Jain
  1 sibling, 0 replies; 5+ messages in thread
From: Anand Jain @ 2020-07-07 14:23 UTC (permalink / raw)
  To: Marcos Paulo de Souza, dsterba, linux-btrfs; +Cc: Marcos Paulo de Souza


Reviewed-by: Anand Jain <anand.jain@oracle.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-07 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06 14:59 [PATCH] btrfs: ctree: Add do {} while (0) in btrfs_{set|clear}_and_info Marcos Paulo de Souza
2020-07-07  8:34 ` Nikolay Borisov
2020-07-07 13:38   ` Marcos Paulo de Souza
2020-07-07 14:10   ` David Sterba
2020-07-07 14:23 ` Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.