The patch titled Subject: minmax-sanity-check-constant-bounds-when-clamping-checkpatch-fixes has been added to the -mm mm-nonmm-unstable branch. Its filename is minmax-sanity-check-constant-bounds-when-clamping-checkpatch-fixes.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/minmax-sanity-check-constant-bounds-when-clamping-checkpatch-fixes.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Subject: minmax-sanity-check-constant-bounds-when-clamping-checkpatch-fixes Date: Mon Oct 17 06:14:56 PM PDT 2022 ERROR: code indent should use tabs where possible #36: FILE: include/linux/minmax.h:50: + (BUILD_BUG_ON_ZERO(__builtin_choose_expr(^I^I^I^I\$ WARNING: please, no spaces at the start of a line #36: FILE: include/linux/minmax.h:50: + (BUILD_BUG_ON_ZERO(__builtin_choose_expr(^I^I^I^I\$ ERROR: code indent should use tabs where possible #37: FILE: include/linux/minmax.h:51: + __is_constexpr((lo) > (hi)), (lo) > (hi), false)))$ WARNING: please, no spaces at the start of a line #37: FILE: include/linux/minmax.h:51: + __is_constexpr((lo) > (hi)), (lo) > (hi), false)))$ WARNING: please, no space before tabs #40: FILE: include/linux/minmax.h:54: +^I__clamp_input_check(lo, hi) + ^I^I^I^I^I^I\$ WARNING: please, no space before tabs #42: FILE: include/linux/minmax.h:56: +^I^I^I __typecheck(hi, lo) && __is_constexpr(val) && ^I\$ total: 2 errors, 4 warnings, 44 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. NOTE: Whitespace errors detected. You may wish to use scripts/cleanpatch or scripts/cleanfile ./patches/minmax-sanity-check-constant-bounds-when-clamping.patch has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. Please run checkpatch prior to sending patches Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: "Jason A. Donenfeld" <Jason@xxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/minmax.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) --- a/include/linux/minmax.h~minmax-sanity-check-constant-bounds-when-clamping-checkpatch-fixes +++ a/include/linux/minmax.h @@ -37,26 +37,26 @@ __cmp(x, y, op), \ __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) -#define __clamp(val, lo, hi) \ +#define __clamp(val, lo, hi) \ __cmp(__cmp(val, lo, >), hi, <) -#define __clamp_once(val, lo, hi, unique_val, unique_lo, unique_hi) ({ \ - typeof(val) unique_val = (val); \ - typeof(lo) unique_lo = (lo); \ - typeof(hi) unique_hi = (hi); \ +#define __clamp_once(val, lo, hi, unique_val, unique_lo, unique_hi) ({ \ + typeof(val) unique_val = (val); \ + typeof(lo) unique_lo = (lo); \ + typeof(hi) unique_hi = (hi); \ __clamp(unique_val, unique_lo, unique_hi); }) -#define __clamp_input_check(lo, hi) \ - (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ +#define __clamp_input_check(lo, hi) \ + (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ __is_constexpr((lo) > (hi)), (lo) > (hi), false))) -#define __careful_clamp(val, lo, hi) ({ \ - __clamp_input_check(lo, hi) + \ - __builtin_choose_expr(__typecheck(val, lo) && __typecheck(val, hi) && \ - __typecheck(hi, lo) && __is_constexpr(val) && \ - __is_constexpr(lo) && __is_constexpr(hi), \ - __clamp(val, lo, hi), \ - __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ +#define __careful_clamp(val, lo, hi) ({ \ + __clamp_input_check(lo, hi) + \ + __builtin_choose_expr(__typecheck(val, lo) && __typecheck(val, hi) &&\ + __typecheck(hi, lo) && __is_constexpr(val) &&\ + __is_constexpr(lo) && __is_constexpr(hi), \ + __clamp(val, lo, hi), \ + __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ __UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); }) /** _ Patches currently in -mm which might be from akpm@xxxxxxxxxxxxxxxxxxxx are mm-hugetlb-convert-free_huge_page-to-folios-fix.patch powerpc-ptrace-user_regset_copyin_ignore-always-returns-0-fix.patch minmax-sanity-check-constant-bounds-when-clamping-checkpatch-fixes.patch