Add missing parentheses around macro parameter use in the following patterns to ensure operator precedence behaves as expected: - "x++" is changed for "(x)++", - x->member is changed for (x)->member, - &x is changed for &(x). - "x = y" is changed for "x = (y)", because "y" can be an expression containing a comma if it is the result of the expansion of a macro such as #define eval(...) __VA_ARGS__, which would cause unexpected operator precedence. This use-case is far-fetched, but we have to choose one way or the other (with or without parentheses) for consistency. Remove useless parentheses in the following macro argument usage patterns: - m((x)) is changed for m(x), - m((x), y) is changed for m(x, y) because comma has lowest operator precedence, making the extra parentheses useless, Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Omar Sandoval <osandov@xxxxxx> Cc: linux-block@xxxxxxxxxxxxxxx --- include/linux/bio.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index b3e7529ff55e..f09aea290511 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -20,7 +20,7 @@ static inline unsigned int bio_max_segs(unsigned int nr_segs) } #define bio_prio(bio) (bio)->bi_ioprio -#define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) +#define bio_set_prio(bio, prio) ((bio)->bi_ioprio = (prio)) #define bio_iter_iovec(bio, iter) \ bvec_iter_bvec((bio)->bi_io_vec, (iter)) @@ -37,7 +37,7 @@ static inline unsigned int bio_max_segs(unsigned int nr_segs) #define bio_iovec(bio) bio_iter_iovec((bio), (bio)->bi_iter) #define bvec_iter_sectors(iter) ((iter).bi_size >> 9) -#define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors((iter))) +#define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors(iter)) #define bio_sectors(bio) bvec_iter_sectors((bio)->bi_iter) #define bio_end_sector(bio) bvec_iter_end_sector((bio)->bi_iter) @@ -93,7 +93,7 @@ static inline bool bio_next_segment(const struct bio *bio, * before it got to the driver and the driver won't own all of it */ #define bio_for_each_segment_all(bvl, bio, iter) \ - for (bvl = bvec_init_iter_all(&iter); bio_next_segment((bio), &iter); ) + for (bvl = bvec_init_iter_all(&(iter)); bio_next_segment(bio, &(iter)); ) static inline void bio_advance_iter(const struct bio *bio, struct bvec_iter *iter, unsigned int bytes) @@ -145,17 +145,17 @@ static inline void bio_advance(struct bio *bio, unsigned int nbytes) #define __bio_for_each_segment(bvl, bio, iter, start) \ for (iter = (start); \ (iter).bi_size && \ - ((bvl = bio_iter_iovec((bio), (iter))), 1); \ - bio_advance_iter_single((bio), &(iter), (bvl).bv_len)) + ((bvl = bio_iter_iovec(bio, iter)), 1); \ + bio_advance_iter_single(bio, &(iter), (bvl).bv_len)) #define bio_for_each_segment(bvl, bio, iter) \ __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter) -#define __bio_for_each_bvec(bvl, bio, iter, start) \ +#define __bio_for_each_bvec(bvl, bio, iter, start) \ for (iter = (start); \ (iter).bi_size && \ - ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, (iter))), 1); \ - bio_advance_iter_single((bio), &(iter), (bvl).bv_len)) + ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, iter)), 1); \ + bio_advance_iter_single(bio, &(iter), (bvl).bv_len)) /* iterate over multi-page bvec */ #define bio_for_each_bvec(bvl, bio, iter) \ @@ -167,7 +167,7 @@ static inline void bio_advance(struct bio *bio, unsigned int nbytes) */ #define bio_for_each_bvec_all(bvl, bio, i) \ for (i = 0, bvl = bio_first_bvec_all(bio); \ - i < (bio)->bi_vcnt; i++, bvl++) + i < (bio)->bi_vcnt; (i)++, (bvl)++) #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) @@ -548,7 +548,7 @@ static inline void bio_list_init(struct bio_list *bl) #define BIO_EMPTY_LIST { NULL, NULL } #define bio_list_for_each(bio, bl) \ - for (bio = (bl)->head; bio; bio = bio->bi_next) + for (bio = (bl)->head; bio; bio = (bio)->bi_next) static inline unsigned bio_list_size(const struct bio_list *bl) { @@ -702,7 +702,7 @@ static inline bool bioset_initialized(struct bio_set *bs) #define bio_for_each_integrity_vec(_bvl, _bio, _iter) \ for_each_bio(_bio) \ - bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) + bip_for_each_vec(_bvl, (_bio)->bi_integrity, _iter) extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); -- 2.25.1