Skip to content

Commit

Permalink
btrfs: add multi-statement protection to btrfs_set/clear_and_info macros
Browse files Browse the repository at this point in the history
Multi-statement macros should be enclosed in do/while(0) block to make
their use safe in single statement if conditions. All current uses of
the macros are safe, so this change is for future protection.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Marcos Paulo de Souza authored and David Sterba committed Jul 27, 2020
1 parent 93c4c03 commit 60f8667
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1279,18 +1279,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.
Expand Down

0 comments on commit 60f8667

Please sign in to comment.