Skip to content

Commit 4ead534

Browse files
david-laightakpm00
authored andcommitted
minmax: allow comparisons of 'int' against 'unsigned char/short'
Since 'unsigned char/short' get promoted to 'signed int' it is safe to compare them against an 'int' value. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Laight <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Jason A. Donenfeld <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f4b84b2 commit 4ead534

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/linux/minmax.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
__builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
2727
is_signed_type(typeof(x)), 0)
2828

29-
#define __types_ok(x, y) \
30-
(__is_signed(x) == __is_signed(y))
29+
#define __types_ok(x, y) \
30+
(__is_signed(x) == __is_signed(y) || \
31+
__is_signed((x) + 0) == __is_signed((y) + 0))
3132

3233
#define __cmp_op_min <
3334
#define __cmp_op_max >

0 commit comments

Comments
 (0)