From patchwork Thu Apr 6 18:57:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=A9r=C3=A9my_Lefaure?= X-Patchwork-Id: 9668099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AEEDB602B3 for ; Thu, 6 Apr 2017 18:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 978A9285C4 for ; Thu, 6 Apr 2017 18:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AD2E285D4; Thu, 6 Apr 2017 18:57:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7153285C4 for ; Thu, 6 Apr 2017 18:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933171AbdDFS5r (ORCPT ); Thu, 6 Apr 2017 14:57:47 -0400 Received: from blatinox.fr ([51.254.120.209]:51528 "EHLO vps202351.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932990AbdDFS5q (ORCPT ); Thu, 6 Apr 2017 14:57:46 -0400 Received: from blatinox-laptop.localdomain (unknown [207.35.173.122]) by vps202351.ovh.net (Postfix) with ESMTPA id BCB581C006; Thu, 6 Apr 2017 20:57:38 +0200 (CEST) From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= , stable@vger.kernel.org Subject: [PATCH] scsi: sd: fix warning on min_not_zero use Date: Thu, 6 Apr 2017 14:57:22 -0400 Message-Id: <20170406185722.4761-1-jeremy.lefaure@lse.epita.fr> X-Mailer: git-send-email 2.12.2 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When calling min_not_zero, both arguments should have the same type. Otherwise the compiler will raise a warning: CC drivers/scsi/sd.o In file included from ./include/linux/list.h:8:0, from ./include/linux/module.h:9, from drivers/scsi/sd.c:35: drivers/scsi/sd.c: In function ‘sd_revalidate_disk’: ./include/linux/kernel.h:755:16: warning: comparison of distinct pointer types lacks a cast (void) (&min1 == &min2); \ ^ ./include/linux/kernel.h:758:2: note: in expansion of macro ‘__min’ __min(typeof(x), typeof(y), \ ^~~~~ ./include/linux/kernel.h:783:39: note: in expansion of macro ‘min’ __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) ^~~ drivers/scsi/sd.c:2959:12: note: in expansion of macro ‘min_not_zero’ rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), ^~~~~~~~~~~~ Casting the BLK_DEF_MAX_SECTORS constant fixes this issue. Cc: # v4.4+ Fixes: c3e62673ee20 ("scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable") Signed-off-by: Jérémy Lefaure --- drivers/scsi/sd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ab9011a6257d..7dce3592033d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2955,9 +2955,10 @@ static int sd_revalidate_disk(struct gendisk *disk) logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) { q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); - } else + } else { rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), - BLK_DEF_MAX_SECTORS); + (sector_t)BLK_DEF_MAX_SECTORS); + } /* Combine with controller limits */ q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));