From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7568574230832093396==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix minmax.cocci warnings Date: Sun, 02 May 2021 07:01:50 +0800 Message-ID: <20210501230150.GA21829@619603c3fe9d> In-Reply-To: <202105020602.wphxzdEk-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============7568574230832093396== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Denis Efremov CC: Julia Lawall CC: Matthew Wilcox CC: Hannes Reinecke 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/advansys.c:7734:45-46: 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 Fixes: 8636e3295ce3 ("coccinelle: misc: add minmax script") CC: Denis Efremov Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git f= or-5.12 head: afa104b04309a6e882f6797216e74489c0d5534f commit: 8636e3295ce33515c50ef728f0ff3800d97f9f44 [1/6] coccinelle: misc: ad= d minmax script :::::: branch date: 4 days ago :::::: commit date: 6 weeks ago Please take the patch only if it's a positive warning. Thanks! advansys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -7731,7 +7731,7 @@ adv_build_req(struct asc_board *boardp, /* Set CDB length and copy it to the request structure. */ scsiqp->cdb_len =3D scp->cmd_len; /* Copy first 12 CDB bytes to cdb[]. */ - memcpy(scsiqp->cdb, scp->cmnd, scp->cmd_len < 12 ? scp->cmd_len : 12); + memcpy(scsiqp->cdb, scp->cmnd, min(scp->cmd_len, 12)); /* Copy last 4 CDB bytes, if present, to cdb16[]. */ if (scp->cmd_len > 12) { int cdb16_len =3D scp->cmd_len - 12; --===============7568574230832093396==--