From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4674789696793877241==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix minmax.cocci warnings Date: Sun, 20 Mar 2022 12:31:12 +0800 Message-ID: <20220320043112.GA5486@344809d7dd0f> In-Reply-To: <202203201206.LGALPb7q-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============4674789696793877241== 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: "Manoj N. Kumar" CC: "Matthew R. Ochs" CC: Uma Krishnan CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/scsi/cxlflash/vlun.c:448:30-31: 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: 34e047aa16c0123bbae8e2f6df33e5ecc1f56601 commit: 5f66f73b9ff4dcabd4e2405ba9c32e80e02f9408 coccinelle: misc: add minm= ax script :::::: branch date: 33 hours ago :::::: commit date: 11 months ago Please take the patch only if it's a positive warning. Thanks! drivers/scsi/cxlflash/vlun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/scsi/cxlflash/vlun.c +++ b/drivers/scsi/cxlflash/vlun.c @@ -445,7 +445,7 @@ static int write_same16(struct scsi_devi scsi_cmd[0] =3D WRITE_SAME_16; scsi_cmd[1] =3D cfg->ws_unmap ? 0x8 : 0; put_unaligned_be64(offset, &scsi_cmd[2]); - put_unaligned_be32(ws_limit < left ? ws_limit : left, + put_unaligned_be32(min(ws_limit, left), &scsi_cmd[10]); = /* Drop the ioctl read semahpore across lengthy call */ --===============4674789696793877241==--