CC: kbuild-all(a)lists.01.org BCC: lkp(a)intel.com CC: linux-kernel(a)vger.kernel.org TO: Denis Efremov CC: Julia Lawall CC: Michael Ellerman CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: linuxppc-dev(a)lists.ozlabs.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot arch/powerpc/kernel/sysfs.c:456:36-37: WARNING opportunity for max() arch/powerpc/kernel/sysfs.c:334:36-37: WARNING opportunity for max() Check for opencoded min(), max() implementations. Generated patches sometimes require adding a cast to fix compile warning. Warnings/patches scope intentionally limited to a function body. Generated by: scripts/coccinelle/misc/minmax.cocci CC: Denis Efremov Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: c00c5e1d157bec0ef0b0b59aa5482eb8dc7e8e49 commit: 5f66f73b9ff4dcabd4e2405ba9c32e80e02f9408 coccinelle: misc: add minmax script :::::: branch date: 10 hours ago :::::: commit date: 12 months ago Please take the patch only if it's a positive warning. Thanks! arch/powerpc/kernel/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -331,7 +331,7 @@ static ssize_t show_pw20_wait_time(struc time = pw20_wt; } - return sprintf(buf, "%llu\n", time > 0 ? time : 0); + return sprintf(buf, "%llu\n", max(time, 0)); } static void set_pw20_wait_entry_bit(void *val) @@ -453,7 +453,7 @@ static ssize_t show_altivec_idle_wait_ti time = altivec_idle_wt; } - return sprintf(buf, "%llu\n", time > 0 ? time : 0); + return sprintf(buf, "%llu\n", max(time, 0)); } static void set_altivec_idle_wait_entry_bit(void *val)