f2fs: Guard macro variables with braces
PATCH 1/1 f2fs: Guard macro variables with braces
From: Tomohiro Kusumi <[email protected]>
Add braces around variables used within macros for those make sense to do it. Many of the macros in f2fs already do this. What this commit doesn't do is anything that changes line# as a result of adding braces, which usually affects the binary via __LINE__.
Confirmed no diff in fs/f2fs/f2fs.ko before/after this commit on x86_64, to make sure this has no functional change as well as there's been no unexpected side effect due to callers' arithmetics within the existing code.
Signed-off-by Tomohiro Kusumi <[email protected]>
--- fs/f2fs/f2fs.h | 40 ++++++++++++++--------------- fs/f2fs/node.c | 2 +- fs/f2fs/node.h | 22 ++++++++-------- fs/f2fs/segment.h | 76 +++++++++++++++++++++++++++---------------------------- fs/f2fs/xattr.h | 4 +-- 5 files changed, 72 insertions(+), 72 deletions(-)
fs/f2fs/f2fs.h +20 -20
@@ -62,7 +62,7 @@ struct f2fs_fault_info { };extern char *fault_name[FAULT_MAX ]; -#define IS_FAULT_SET (fi, type) (fi->inject_type & (1 << (type))) +#define IS_FAULT_SET (fi, type) ((fi)->inject_type & (1 << (type)))#endif /*
@@ -88,9 +88,9 @@ extern char *fault_name[FAULT_MAX];#define F2FS_MOUNT_ADAPTIVE 0x00020000#define F2FS_MOUNT_LFS 0x00040000 -#define clear_opt (sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option) -#define set_opt (sbi, option) (sbi->mount_opt.opt |= F2FS_MOUNT_##option) -#define test_opt (sbi, option) (sbi->mount_opt.opt & F2FS_MOUNT_##option) +#define clear_opt (sbi, option) ((sbi)->mount_opt.opt &= ~F2FS_MOUNT_##option) +#define set_opt (sbi, option) ((sbi)->mount_opt.opt |= F2FS_MOUNT_##option) +#define test_opt (sbi, option) ((sbi)->mount_opt.opt & F2FS_MOUNT_##option)#define ver_after (a, b) (typecheck(unsigned long long, a) && \ typecheck(unsigned long long, b) && \
@@ -222,13 +222,13 @@ struct fsync_inode_entry {block_t last_dentry;/* block address locating the last dentry */ }; -#define nats_in_cursum (jnl) (le16_to_cpu(jnl->n_nats)) -#define sits_in_cursum (jnl) (le16_to_cpu(jnl->n_sits)) +#define nats_in_cursum (jnl) (le16_to_cpu((jnl)->n_nats)) +#define sits_in_cursum (jnl) (le16_to_cpu((jnl)->n_sits)) -#define nat_in_journal (jnl, i) (jnl->nat_j.entries[i].ne) -#define nid_in_journal (jnl, i) (jnl->nat_j.entries[i].nid) -#define sit_in_journal (jnl, i) (jnl->sit_j.entries[i].se) -#define segno_in_journal (jnl, i) (jnl->sit_j.entries[i].segno) +#define nat_in_journal (jnl, i) ((jnl)->nat_j.entries[i].ne) +#define nid_in_journal (jnl, i) ((jnl)->nat_j.entries[i].nid) +#define sit_in_journal (jnl, i) ((jnl)->sit_j.entries[i].se) +#define segno_in_journal (jnl, i) ((jnl)->sit_j.entries[i].segno)#define MAX_NAT_JENTRIES (jnl) (NAT_JOURNAL_ENTRIES - nats_in_cursum(jnl))#define MAX_SIT_JENTRIES (jnl) (SIT_JOURNAL_ENTRIES - sits_in_cursum(jnl))
@@ -737,7 +737,7 @@ struct f2fs_io_info {bool submitted;/* indicate IO submission */ }; -#define is_read_io (rw) (rw == READ) +#define is_read_io (rw) ((rw) == READ)struct f2fs_bio_info {struct f2fs_sb_info *sbi;/* f2fs superblock */ struct bio *bio;/* bios to merge */
@@ -969,8 +969,8 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)* and the return value is in kbytes. s is of struct f2fs_sb_info. */ #define BD_PART_WRITTEN (s) \ -(((u64)part_stat_read(s->sb->s_bdev->bd_part, sectors[1]) - \ - s->sectors_written_start) >> 1) +(((u64)part_stat_read((s)->sb->s_bdev->bd_part, sectors[1]) - \ + (s)->sectors_written_start) >> 1)static inline void f2fs_update_time (struct f2fs_sb_info *sbi,int type) {
@@ -2029,8 +2029,8 @@ static inline void *f2fs_kvzalloc(size_t size, gfp_t flags)/* get offset of first page in next direct node */ #define PGOFS_OF_NEXT_DNODE (pgofs, inode) \ - ((pgofs < ADDRS_PER_INODE(inode)) ? ADDRS_PER_INODE(inode) : \ - (pgofs - ADDRS_PER_INODE(inode) + ADDRS_PER_BLOCK) / \ + (((pgofs) < ADDRS_PER_INODE(inode)) ? ADDRS_PER_INODE(inode) : \ + ((pgofs) - ADDRS_PER_INODE(inode) + ADDRS_PER_BLOCK) / \ ADDRS_PER_BLOCK * ADDRS_PER_BLOCK + ADDRS_PER_INODE(inode))/*
@@ -2422,8 +2422,8 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)#define stat_inc_seg_count (sbi, type, gc_type) \ do { \ struct f2fs_stat_info *si = F2FS_STAT(sbi); \ - (si)->tot_segs++; \ - if (type == SUM_TYPE_DATA) { \ + si->tot_segs++; \ + if ((type) == SUM_TYPE_DATA) { \ si->data_segs++; \ si->bg_data_segs += (gc_type == BG_GC) ? 1 : 0; \ } else { \
@@ -2433,14 +2433,14 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) } while (0)#define stat_inc_tot_blk_count (si, blks) \ - (si->tot_blks += (blks)) + ((si)->tot_blks += (blks))#define stat_inc_data_blk_count (sbi, blks, gc_type) \ do { \ struct f2fs_stat_info *si = F2FS_STAT(sbi); \ stat_inc_tot_blk_count(si, blks); \ si->data_blks += (blks); \ - si->bg_data_blks += (gc_type == BG_GC) ? (blks) : 0; \ + si->bg_data_blks += ((gc_type) == BG_GC) ? (blks) : 0; \ } while (0)#define stat_inc_node_blk_count (sbi, blks, gc_type) \
@@ -2448,7 +2448,7 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)struct f2fs_stat_info *si =F2FS_STAT (sbi); \stat_inc_tot_blk_count (si, blks); \ si->node_blks += (blks); \ - si->bg_node_blks += (gc_type ==BG_GC ) ? (blks) :0 ; \ + si->bg_node_blks += ((gc_type) ==BG_GC ) ? (blks) :0 ; \ }while (0 ) int f2fs_build_stats(struct f2fs_sb_info *sbi);
fs/f2fs/node.c +1 -1
@@ -22,7 +22,7 @@#include "trace.h" #include <trace/events/f2fs.h> -#define on_build_free_nids (nmi) mutex_is_locked(&nm_i->build_lock) +#define on_build_free_nids (nmi) mutex_is_locked(&(nm_i)->build_lock)static struct kmem_cache *nat_entry_slab;static struct kmem_cache *free_nid_slab;
fs/f2fs/node.h +11 -11
@@ -9,10 +9,10 @@* published by the Free Software Foundation. */ /* start node id of a node block dedicated to the given node id */ -#define START_NID (nid) ((nid / NAT_ENTRY_PER_BLOCK) * NAT_ENTRY_PER_BLOCK) +#define START_NID (nid) (((nid) / NAT_ENTRY_PER_BLOCK) * NAT_ENTRY_PER_BLOCK)/* node block offset on the NAT area dedicated to the given start node id */ -#define NAT_BLOCK_OFFSET (start_nid) (start_nid / NAT_ENTRY_PER_BLOCK) +#define NAT_BLOCK_OFFSET (start_nid) ((start_nid) / NAT_ENTRY_PER_BLOCK)/* # of pages to perform synchronous readahead before building free nids */ #define FREE_NID_PAGES 8
@@ -62,16 +62,16 @@ struct nat_entry {struct node_info ni;/* in-memory node information */ }; -#define nat_get_nid (nat) (nat->ni.nid) -#define nat_set_nid (nat, n) (nat->ni.nid = n) -#define nat_get_blkaddr (nat) (nat->ni.blk_addr) -#define nat_set_blkaddr (nat, b) (nat->ni.blk_addr = b) -#define nat_get_ino (nat) (nat->ni.ino) -#define nat_set_ino (nat, i) (nat->ni.ino = i) -#define nat_get_version (nat) (nat->ni.version) -#define nat_set_version (nat, v) (nat->ni.version = v) +#define nat_get_nid (nat) ((nat)->ni.nid) +#define nat_set_nid (nat, n) ((nat)->ni.nid = (n)) +#define nat_get_blkaddr (nat) ((nat)->ni.blk_addr) +#define nat_set_blkaddr (nat, b) ((nat)->ni.blk_addr = (b)) +#define nat_get_ino (nat) ((nat)->ni.ino) +#define nat_set_ino (nat, i) ((nat)->ni.ino = (i)) +#define nat_get_version (nat) ((nat)->ni.version) +#define nat_set_version (nat, v) ((nat)->ni.version = (v)) -#define inc_node_version (version) (++version) +#define inc_node_version (version) (++(version))static inline void copy_node_info (struct node_info *dst,struct node_info *src)
fs/f2fs/segment.h +38 -38
123 lines not on this page · raw message
fs/f2fs/xattr.h +2 -2
@@ -58,10 +58,10 @@ struct f2fs_xattr_entry {#define XATTR_FIRST_ENTRY (ptr) (XATTR_ENTRY(XATTR_HDR(ptr) + 1))#define XATTR_ROUND (3) -#define XATTR_ALIGN (size) ((size + XATTR_ROUND) & ~XATTR_ROUND) +#define XATTR_ALIGN (size) (((size) + XATTR_ROUND) & ~XATTR_ROUND)#define ENTRY_SIZE (entry) (XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + \ - entry->e_name_len + le16_to_cpu(entry->e_value_size))) + (entry)->e_name_len + le16_to_cpu((entry)->e_value_size)))#define XATTR_NEXT_ENTRY (entry) ((struct f2fs_xattr_entry *)((char *)(entry) +\ ENTRY_SIZE(entry)))
Signature · 6 lines
2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot