From patchwork Thu Mar 15 15:08:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10284731 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 5208860386 for ; Thu, 15 Mar 2018 15:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 466A128A57 for ; Thu, 15 Mar 2018 15:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B43728B1F; Thu, 15 Mar 2018 15:08:41 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C30BC28A57 for ; Thu, 15 Mar 2018 15:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752747AbeCOPIj (ORCPT ); Thu, 15 Mar 2018 11:08:39 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:46680 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752780AbeCOPI3 (ORCPT ); Thu, 15 Mar 2018 11:08:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1521127617; x=1552663617; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=gEHIsEXJUhFjPUWf6DRHO6HvKS0YKSVxnUqyiHKcLtQ=; b=lHFnGiV+SGK3INERJt9rB9fJfPDMWAkZbVlt9HIKOpDtktoov1Mhh4mk aWpgD6P/mZSzNciyg/2rm4839iLVYH+x/qWgwxEZHs654Yq0xqDoBdhx2 nEhcJSpruXHJ1ZxH6EygcpB4f2stMvxn4mddUALbEU7X+812XnBj5vApJ sA5wFq9Opj1H8SZGdtoodV+fGlfAD3T61YRXyasBKDIWSdGcEgmEhG7Ym RfVoCUN+CTTNPfTr6TdjuH2aIZTPzxroLQGTDx14OEvJh8oQ9Dy5kzsgn Y1K/BfTWzlAtwQuKpj7iSWtxI8z63pOxexnl1Q8aLrMGM5lffQCePTZHJ Q==; X-IronPort-AV: E=Sophos;i="5.47,471,1515427200"; d="scan'208";a="170233268" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Mar 2018 23:26:37 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 15 Mar 2018 08:01:14 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 15 Mar 2018 08:08:16 -0700 From: Bart Van Assche To: Michael Lyle , Kent Overstreet , Coly Li Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche Subject: [PATCH 08/16] bcache: Fix a compiler warning in bcache_device_init() Date: Thu, 15 Mar 2018 08:08:06 -0700 Message-Id: <20180315150814.9412-9-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180315150814.9412-1-bart.vanassche@wdc.com> References: <20180315150814.9412-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Avoid that building with W=1 triggers the following compiler warning: drivers/md/bcache/super.c:776:20: warning: comparison is always false due to limited range of data type [-Wtype-limits] d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { ^ Signed-off-by: Bart Van Assche Reviewed-by: Coly Li --- drivers/md/bcache/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index e8dfa804bd98..87c1f853bbb3 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -769,6 +769,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size, sector_t sectors) { struct request_queue *q; + const size_t max_stripes = min_t(size_t, INT_MAX, + SIZE_MAX / sizeof(atomic_t)); size_t n; int idx; @@ -777,9 +779,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size, d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size); - if (!d->nr_stripes || - d->nr_stripes > INT_MAX || - d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { + if (!d->nr_stripes || d->nr_stripes > max_stripes) { pr_err("nr_stripes too large or invalid: %u (start sector beyond end of disk?)", (unsigned)d->nr_stripes); return -ENOMEM;