diff options
author | David Laight <[email protected]> | 2023-09-18 08:17:15 +0000 |
---|---|---|
committer | Andrew Morton <[email protected]> | 2023-10-18 14:43:22 -0700 |
commit | d03eba99f5bf7cbc6e2fdde3b6fa36954ad58e09 (patch) | |
tree | 39bb17b041664cbc3f8495b363ef07e2ee96ce3b /lib/test_fortify/write_overflow-strncpy-src.c | |
parent | 80fcac55385ccb710d33a20dc1caaef29bd5a921 (diff) |
minmax: allow min()/max()/clamp() if the arguments have the same signedness.
The type-check in min()/max() is there to stop unexpected results if a
negative value gets converted to a large unsigned value. However it also
rejects 'unsigned int' v 'unsigned long' compares which are common and
never problematc.
Replace the 'same type' check with a 'same signedness' check.
The new test isn't itself a compile time error, so use static_assert() to
report the error and give a meaningful error message.
Due to the way builtin_choose_expr() works detecting the error in the
'non-constant' side (where static_assert() can be used) also detects
errors when the arguments are constant.
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]>
Diffstat (limited to 'lib/test_fortify/write_overflow-strncpy-src.c')
0 files changed, 0 insertions, 0 deletions