From patchwork Mon Mar 19 00:36:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10291493 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 853D060291 for ; Mon, 19 Mar 2018 00:37:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78F0928D4B for ; Mon, 19 Mar 2018 00:37:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C3E428F6F; Mon, 19 Mar 2018 00:37:16 +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,DKIM_SIGNED, DKIM_VALID,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 112B328D4B for ; Mon, 19 Mar 2018 00:37:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754850AbeCSAhP (ORCPT ); Sun, 18 Mar 2018 20:37:15 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:45175 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754841AbeCSAhE (ORCPT ); Sun, 18 Mar 2018 20:37:04 -0400 Received: by mail-pf0-f193.google.com with SMTP id l27so1841333pfk.12 for ; Sun, 18 Mar 2018 17:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cUjKosOe+WKbP2LoNhHlnx46CwwWfcrLwmhucYJQgFQ=; b=0CCft1DZ84NhWs1wrwpkbmkL6UZCO8TZyldIR3VQw6H26KtO3Tu0l6DA1EYF2t+itm amYwLRjRuJTcbcsM2AZWHFuP1BHwOUM9y8i/scG16HMaM6B+7UYUSagzOQo1nPmHW78W WZcDJJv5B0BlubDdavDVh87ephW/PE5ZHQnH5tGXDjvCjPXVm4bu0oZNlk/yzgfOesbd S73I/cWZMJJZlr7rhNnBpG5rmsCeuE9e/0dsbIWXdjSS2xu08LMdEpTd+zc+hpkBgMxG GxTWIWzAumotvXjVVkGF5F8J4pjthW6iPNfuIv2DYSAm8ITEBoSR5fd7MsSP8y0wafoR QBRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cUjKosOe+WKbP2LoNhHlnx46CwwWfcrLwmhucYJQgFQ=; b=YLsg9cuLR+36Af9z+HZkLRjU+JFD0jEn2jAETLruoRja+8TaDMLpGWTFxohg+8qkjk b2MMCPeXkx0MiZiyWxkEp2mbw6/VUiNe7bQxHvrF8RWxZvN5V8b2NWkOLYMRfixwP6sT nm1rEJTUOw1KNR4DvQPx1fbVbZCLTxmB63Qvs/+jgm0D4Uk37bW9ok6oVfE4TyO0PELj Ddsfrh4w7p7MdMWO6TYxpPE75rYTfmWg67CRGh6kbauoToRo2bYlS/4iG3JA2fomEPoc Nre0T6F0N1yGpnCUgaMWrPbchbObnqeB9i8x9PBtuthoWW0s8FvMqHHhudIH1RzTd5GH 497A== X-Gm-Message-State: AElRT7F+2DtVmIsHrz5XWl4I6nFtE6e5f2c6SJTH7bAA5C8Ct2w66B7Y QZqRaRWwIVTY5344oXaoYHF2vg== X-Google-Smtp-Source: AG47ELsRVhJcHOcD3Uwf6xy5xD1oVgTc4+77mhSrUb0tl4rPAWT2oIL/ZLMa7ef15ADlgB3IWDpnXg== X-Received: by 10.101.74.77 with SMTP id a13mr7857422pgu.32.1521419824102; Sun, 18 Mar 2018 17:37:04 -0700 (PDT) Received: from midnight.lan (2600-6c52-6200-09b7-0000-0000-0000-0d66.dhcp6.chtrptr.net. [2600:6c52:6200:9b7::d66]) by smtp.gmail.com with ESMTPSA id a17sm27674857pfc.122.2018.03.18.17.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Mar 2018 17:37:03 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Bart Van Assche Subject: [for-4.17 20/20] bcache: Fix a compiler warning in bcache_device_init() Date: Sun, 18 Mar 2018 17:36:33 -0700 Message-Id: <20180319003633.27225-21-mlyle@lyle.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180319003633.27225-1-mlyle@lyle.org> References: <20180319003633.27225-1-mlyle@lyle.org> 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 From: Bart Van Assche 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: Michael Lyle --- 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 640ff8072ed8..d90d9e59ca00 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -778,6 +778,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; @@ -786,9 +788,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;