From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4111270688540673249==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] coccinelle: misc: fix minmax.cocci warnings Date: Sat, 24 Apr 2021 09:32:22 +0800 Message-ID: <20210424013222.GA81760@e7820565f5da> In-Reply-To: <202104240943.fvm6HjPc-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============4111270688540673249== 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: Jens Axboe CC: linux-ide(a)vger.kernel.org CC: linux-kernel(a)vger.kernel.org From: kernel test robot drivers/ata/libata-scsi.c:3594:10-11: WARNING opportunity for min() drivers/ata/libata-scsi.c:3650:10-11: 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: 44e793b89bcfe586730f4c6ce3c66174dc07cb37 commit: 8636e3295ce33515c50ef728f0ff3800d97f9f44 [1/5] coccinelle: misc: ad= d minmax script :::::: branch date: 15 hours ago :::::: commit date: 5 weeks ago Please take the patch only if it's a positive warning. Thanks! libata-scsi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3591,10 +3591,7 @@ static int ata_mselect_caching(struct at */ = if (len !=3D CACHE_MPAGE_LEN - 2) { - if (len < CACHE_MPAGE_LEN - 2) - *fp =3D len; - else - *fp =3D CACHE_MPAGE_LEN - 2; + *fp =3D min(len, CACHE_MPAGE_LEN - 2); return -EINVAL; } = @@ -3647,10 +3644,7 @@ static int ata_mselect_control(struct at */ = if (len !=3D CONTROL_MPAGE_LEN - 2) { - if (len < CONTROL_MPAGE_LEN - 2) - *fp =3D len; - else - *fp =3D CONTROL_MPAGE_LEN - 2; + *fp =3D min(len, CONTROL_MPAGE_LEN - 2); return -EINVAL; } =20 --===============4111270688540673249==--