From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3381058763368600303==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix minmax.cocci warnings Date: Sun, 02 May 2021 09:01:47 +0800 Message-ID: <20210502010147.GA16766@43098db6d9e0> In-Reply-To: <202105020845.qMwklVPu-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============3381058763368600303== 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: Don Brace CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: storagedev(a)microchip.com CC: linux-scsi(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/scsi/hpsa.c:2668:28-29: WARNING opportunity for min() drivers/scsi/hpsa.c:3634:34-36: 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! hpsa.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -2665,10 +2665,8 @@ static void complete_scsi_command(struct case CMD_TARGET_STATUS: cmd->result |=3D ei->ScsiStatus; /* copy the sense data */ - if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo)) - sense_data_size =3D SCSI_SENSE_BUFFERSIZE; - else - sense_data_size =3D sizeof(ei->SenseInfo); + sense_data_size =3D min(SCSI_SENSE_BUFFERSIZE, + sizeof(ei->SenseInfo)); if (ei->SenseLen < sense_data_size) sense_data_size =3D ei->SenseLen; memcpy(cmd->sense_buffer, ei->SenseInfo, sense_data_size); @@ -3631,10 +3629,7 @@ static bool hpsa_vpd_page_supported(stru if (rc !=3D 0) goto exit_unsupported; pages =3D buf[3]; - if ((pages + HPSA_VPD_HEADER_SZ) <=3D 255) - bufsize =3D pages + HPSA_VPD_HEADER_SZ; - else - bufsize =3D 255; + bufsize =3D min(pages + HPSA_VPD_HEADER_SZ, 255); = /* Get the whole VPD page list */ rc =3D hpsa_scsi_do_inquiry(h, scsi3addr, --===============3381058763368600303==--