Commit b29a7a8e authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Linus Torvalds
Browse files

fs: fuse: fix max() of incompatible types



The 'max()' value of a 'long long' and an 'unsigned int' is problematic
if the former is negative:

In function 'fuse_wr_pages',
    inlined from 'fuse_perform_write' at fs/fuse/file.c:1347:27:
include/linux/compiler_types.h:652:45: error: call to '__compiletime_assert_390' declared with attribute error: min(((pos + len - 1) >> 12) - (pos >> 12) + 1, max_pages) signedness error
  652 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |                                             ^

Use a temporary variable to make it clearer what is going on here.

Fixes: 0f5bb0cf ("fs: use min() or umin() instead of min_t()")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9e355113
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1323,8 +1323,10 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
static inline unsigned int fuse_wr_pages(loff_t pos, size_t len,
				     unsigned int max_pages)
{
	return min(((pos + len - 1) >> PAGE_SHIFT) - (pos >> PAGE_SHIFT) + 1,
		   max_pages);
	unsigned int pages = ((pos + len - 1) >> PAGE_SHIFT) -
			     (pos >> PAGE_SHIFT) + 1;

	return min(pages, max_pages);
}

static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii)