2021-03-04 06:04:52

by Chao Yu

[permalink] [raw]
Subject: [PATCH] f2fs: fix compile warning

node.c: In function ‘f2fs_restore_node_summary’:
./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
^
./include/linux/minmax.h:32:4: note: in expansion of macro ‘__typecheck’
(__typecheck(x, y) && __no_side_effects(x, y))
^
./include/linux/minmax.h:42:24: note: in expansion of macro ‘__safe_cmp’
__builtin_choose_expr(__safe_cmp(x, y), \
^
./include/linux/minmax.h:51:19: note: in expansion of macro ‘__careful_cmp’
#define min(x, y) __careful_cmp(x, y, <)
^
node.c:2750:13: note: in expansion of macro ‘min’
nrpages = min(last_offset - i, BIO_MAX_PAGES);

Use min_t() rather than min() to do type cast before comparing.

Signed-off-by: Chao Yu <[email protected]>
---
fs/f2fs/node.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index a8a0fb890e8d..77f9ffaf9b8e 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2747,7 +2747,8 @@ int f2fs_restore_node_summary(struct f2fs_sb_info *sbi,
sum_entry = &sum->entries[0];

for (i = 0; i < last_offset; i += nrpages, addr += nrpages) {
- nrpages = min(last_offset - i, BIO_MAX_PAGES);
+ nrpages = min_t(unsigned long, last_offset - i,
+ BIO_MAX_PAGES);

/* readahead node pages */
f2fs_ra_meta_pages(sbi, addr, nrpages, META_POR, true);
--
2.29.2