CC: kbuild-...@lists.01.org
TO: Denis Efremov <efre...@linux.com>
CC: Julia Lawall <julia.law...@inria.fr>
CC: Jens Axboe <ax...@kernel.dk>
CC: linux-...@vger.kernel.org
CC: linux-ker...@vger.kernel.org

From: kernel test robot <l...@intel.com>

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 <efre...@linux.com>
Reported-by: kernel test robot <l...@intel.com>
Signed-off-by: kernel test robot <l...@intel.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux.git 
for-5.12
head:   44e793b89bcfe586730f4c6ce3c66174dc07cb37
commit: 8636e3295ce33515c50ef728f0ff3800d97f9f44 [1/5] coccinelle: misc: add 
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 != CACHE_MPAGE_LEN - 2) {
-               if (len < CACHE_MPAGE_LEN - 2)
-                       *fp = len;
-               else
-                       *fp = CACHE_MPAGE_LEN - 2;
+               *fp = min(len, CACHE_MPAGE_LEN - 2);
                return -EINVAL;
        }
 
@@ -3647,10 +3644,7 @@ static int ata_mselect_control(struct at
         */
 
        if (len != CONTROL_MPAGE_LEN - 2) {
-               if (len < CONTROL_MPAGE_LEN - 2)
-                       *fp = len;
-               else
-                       *fp = CONTROL_MPAGE_LEN - 2;
+               *fp = min(len, CONTROL_MPAGE_LEN - 2);
                return -EINVAL;
        }
 
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to