Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 0f5bb0cfb0b4 ("fs: use min() or umin() instead of min_t()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Arnd Bergmann and committed by
Linus Torvalds
b29a7a8e 9e355113

+4 -2
+4 -2
fs/fuse/file.c
··· 1323 1323 static inline unsigned int fuse_wr_pages(loff_t pos, size_t len, 1324 1324 unsigned int max_pages) 1325 1325 { 1326 - return min(((pos + len - 1) >> PAGE_SHIFT) - (pos >> PAGE_SHIFT) + 1, 1327 - max_pages); 1326 + unsigned int pages = ((pos + len - 1) >> PAGE_SHIFT) - 1327 + (pos >> PAGE_SHIFT) + 1; 1328 + 1329 + return min(pages, max_pages); 1328 1330 } 1329 1331 1330 1332 static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii)