From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============2692804487659333463==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix minmax.cocci warnings Date: Mon, 28 Feb 2022 03:44:16 +0800 Message-ID: <20220227194416.GA130226@f78d9763d5c9> In-Reply-To: <202202280325.7VS7xl3Q-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============2692804487659333463== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: "Greg Kroah-Hartman" CC: linux-staging(a)lists.linux.dev CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/staging/most/video/video.c:176:22-23: WARNING opportunity for min() 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: 2293be58d6a18cab800e25e42081bacb75c05752 commit: 5f66f73b9ff4dcabd4e2405ba9c32e80e02f9408 coccinelle: misc: add minm= ax script :::::: branch date: 24 hours ago :::::: commit date: 10 months ago Please take the patch only if it's a positive warning. Thanks! drivers/staging/most/video/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -173,7 +173,7 @@ static ssize_t comp_vdev_read(struct fil while (count > 0 && data_ready(mdev)) { struct mbo *const mbo =3D get_top_mbo(mdev); int const rem =3D mbo->processed_length - fh->offs; - int const cnt =3D rem < count ? rem : count; + int const cnt =3D min(rem, count); = if (copy_to_user(buf, mbo->virt_address + fh->offs, cnt)) { v4l2_err(&mdev->v4l2_dev, "read: copy_to_user failed\n"); --===============2692804487659333463==--