From patchwork Thu Mar 15 15:08:08 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: 10284719 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 232026061F for ; Thu, 15 Mar 2018 15:08:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1887D28A57 for ; Thu, 15 Mar 2018 15:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CF0528B1C; Thu, 15 Mar 2018 15:08:36 +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 B0AC928B0B for ; Thu, 15 Mar 2018 15:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752759AbeCOPId (ORCPT ); Thu, 15 Mar 2018 11:08:33 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:4231 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752795AbeCOPIc (ORCPT ); Thu, 15 Mar 2018 11:08:32 -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=1521127621; x=1552663621; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=507LD+yHmElDk6BMiHvskRqXlTt8HIQ2E3fI74FHTgQ=; b=cCh2k3+T8t0FFEo2FFVbgmSVQsU9e3ZGS8ZXa0quVxnzhaFINfSVPftq +D6vfrjhbAO1hYe48b1kqfOG6ougnOc4MvHYZeOzqQ7zgPxOUGmGvHX41 jKEIPOPn8tN0IkaGKQ0Kb0hSE1TKWrLb54CdXGR1/xwgqLZDxL+5W4T8E zl7l3l8Z3+kHqhUren5KRocsWbtanNIP+tSV8LJAuA39w7uc5GNPjQu4J Bz9WRGXsUQZk2ZXnMv54I43N5bLJbXxqFEtRtXw0IcZFFx1HawB2kfWCs +FDsYNZBrRvhvY9Ped69kxnFx3qVF6T/Bclf2XqmPpuD9O4rA2amlpzPN Q==; X-IronPort-AV: E=Sophos;i="5.47,471,1515427200"; d="scan'208";a="170233272" 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:17 -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 10/16] bcache: Suppress a compiler warning in bch_##name##_h() Date: Thu, 15 Mar 2018 08:08:08 -0700 Message-Id: <20180315150814.9412-11-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/util.c: In function 'bch_strtoull_h': drivers/md/bcache/util.c:70:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] (i < 0 && -ANYSINT_MAX(type) / 1024 > i)) \ ^ The only functional change in this patch is that (type) ~0 is changed into ~(type)0. That makes a difference for unsigned types for which sizeof(type) > sizeof(int). I think this change is a bug fix. Signed-off-by: Bart Van Assche --- drivers/md/bcache/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 74febd5230df..755523474649 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -25,6 +25,7 @@ int bch_ ## name ## _h(const char *cp, type *res) \ int u = 0; \ char *e; \ type i = simple_ ## name(cp, &e, 10); \ + const type zero = 0; \ \ switch (tolower(*e)) { \ default: \ @@ -63,11 +64,10 @@ int bch_ ## name ## _h(const char *cp, type *res) \ return -EINVAL; \ \ while (u--) { \ - if ((type) ~0 > 0 && \ - (type) ~0 / 1024 <= i) \ + if (~zero > 0 && ~zero / 1024 <= i) \ return -EINVAL; \ - if ((i > 0 && ANYSINT_MAX(type) / 1024 < i) || \ - (i < 0 && -ANYSINT_MAX(type) / 1024 > i)) \ + if ((i > zero && ANYSINT_MAX(type) / 1024 < i) ||\ + (i < zero && -ANYSINT_MAX(type) / 1024 > i))\ return -EINVAL; \ i *= 1024; \ } \