Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1527429ybg; Thu, 4 Jun 2020 11:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWaMzTNch7MShXHK0Jh5B9iXT+c0t0XkJ2SRh5lFrTzctrgFd/QLMbU/lSHr+5dNpyl+Ug X-Received: by 2002:a50:934e:: with SMTP id n14mr5741224eda.88.1591297130397; Thu, 04 Jun 2020 11:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591297130; cv=none; d=google.com; s=arc-20160816; b=MQi9qupoMKIpXCD0DB0zhnLIeZALi1J+t1FYFROkSgUulOs5qEnNe6IoWcji+Ivyhc xNu80qWuSh0QqaL22ngM6ovg2yT5D1oXslu1m7XmWe1RCeGgYXYxdewNkhh+Tc9584/7 /imweVDk2HmMXggTrO/ICk9jMG1Attj7EHDmtSUzsYmoA40ft2uQ9fiW4oJ6JVcA7WBh HcVlC8FHg5GUMJEfN3ks8/eANBA3IpQ2Gu7Y4Ju410duVohQjAj79GuXkMnlJCq26I6i mYOkqtDb8CrYnzbnZdJkJmntlNO86VV/+Zf1gUav2Aw+75RdBpYfQ/rj7OFM4JdT9RLv sqoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=8StXtdtPgMxEu2POARWfGPJwlRQHFn7T7CU6R5noutg=; b=WksbDLgArn3TALn6PvFhBX+2OaOw+rfT7mPs3xzWNRIYNj/UCUDA+sBHb/NXwKtAdc LsnXXFLYCwx8XVe4wMgDrI9lhE7cb180qCLQBFuNjFqHKYgxgjBajVrxo/PbxBy+p63m nsDDi97XLJXvRemKWZ/ibFP/xRTANbzSgFHQCM5OjAckv+EGlEAFVWvsjMCFln7qIBQH 1eFIoZCBQjxJo3f5uyX0eYD/2V19m/lrrvVsvuxSFgDuPlwAEFIZYKhz1hbVjrzWpx5G /bUK1CyyJeQFlaQCvJB+ZlsWPiG97cjkhr0+2DLcsoK3z0gi8yLUHa2jPecSfrhq+NQ8 kLoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si2072461ejt.606.2020.06.04.11.58.27; Thu, 04 Jun 2020 11:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbgFDQtz (ORCPT + 99 others); Thu, 4 Jun 2020 12:49:55 -0400 Received: from smtprelay0196.hostedemail.com ([216.40.44.196]:39834 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729115AbgFDQtx (ORCPT ); Thu, 4 Jun 2020 12:49:53 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id 5E9B0503E9; Thu, 4 Jun 2020 16:49:51 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1539:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:2915:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6742:10004:10400:10848:11026:11232:11473:11658:11914:12296:12297:12555:12740:12760:12895:12986:13069:13161:13229:13311:13357:13439:14659:14721:21080:21627:21990:30054:30060:30069:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: field18_4511ff726d98 X-Filterd-Recvd-Size: 2054 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Thu, 4 Jun 2020 16:49:49 +0000 (UTC) Message-ID: <28b33db24b1dbd15cd6711cd473f1c0e5f801e74.camel@perches.com> Subject: Re: [PATCH] linux/bits.h: fix unsigned less than zero warnings From: Joe Perches To: Andy Shevchenko , Rikard Falkeborn Cc: Andrew Morton , Arnd Bergmann , emil.l.velikov@gmail.com, Kees Cook , Linus Walleij , Linux-Arch , Linux Kernel Mailing List , Syed Nayyar Waris , William Breathitt Gray , Masahiro Yamada , kbuild test robot Date: Thu, 04 Jun 2020 09:49:46 -0700 In-Reply-To: References: <20200603215314.GA916134@rikard> <20200603220226.916269-1-rikard.falkeborn@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.2-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-06-04 at 09:41 +0300, Andy Shevchenko wrote: > I think there is still a possibility to improve (as I mentioned there > are test cases that are absent right now). > What if we will have unsigned long value 0x100000001? Would it be 1 > after casting? > > Maybe cast to (long) or (long long) more appropriate? Another good mechanism would be to compile-time check the use of constants in BITS and BITS_ULL and verify that: range of BITS is: >= 0 && < (BITS_PER_BYTE * sizeof(unsigned int)) range of BITS_ULL is: >= 0 && < (BITS_PER_BYTE * sizeof(unsigned long long)) There would be duplication similar to the GENMASK_INPUT_CHECK macros.