Skip to content

Commit 60f8667

Browse files
marcospskdave
authored andcommitted
btrfs: add multi-statement protection to btrfs_set/clear_and_info macros
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 <[email protected]> Signed-off-by: Marcos Paulo de Souza <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 93c4c03 commit 60f8667

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/btrfs/ctree.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,18 +1279,18 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
12791279
BTRFS_MOUNT_##opt)
12801280

12811281
#define btrfs_set_and_info(fs_info, opt, fmt, args...) \
1282-
{ \
1282+
do { \
12831283
if (!btrfs_test_opt(fs_info, opt)) \
12841284
btrfs_info(fs_info, fmt, ##args); \
12851285
btrfs_set_opt(fs_info->mount_opt, opt); \
1286-
}
1286+
} while (0)
12871287

12881288
#define btrfs_clear_and_info(fs_info, opt, fmt, args...) \
1289-
{ \
1289+
do { \
12901290
if (btrfs_test_opt(fs_info, opt)) \
12911291
btrfs_info(fs_info, fmt, ##args); \
12921292
btrfs_clear_opt(fs_info->mount_opt, opt); \
1293-
}
1293+
} while (0)
12941294

12951295
/*
12961296
* Requests for changes that need to be done during transaction commit.

0 commit comments

Comments
 (0)