From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============9157302984791210032==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix minmax.cocci warnings Date: Wed, 09 Feb 2022 05:54:37 +0800 Message-ID: <20220208215437.GA28779@ce21ee696918> In-Reply-To: <202202090521.NbGseFCj-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============9157302984791210032== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org 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: 555f3d7be91a873114c9656069f1a9fa476ec41a commit: 5f66f73b9ff4dcabd4e2405ba9c32e80e02f9408 coccinelle: misc: add minm= ax script :::::: branch date: 22 hours ago :::::: commit date: 9 months ago Please take the patch only if it's a positive warning. Thanks! 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 =3D 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 =3D 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) --===============9157302984791210032==--