Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5920182ybl; Tue, 27 Aug 2019 11:34:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRspnb2v2LvopPiF0HopkJ6g2IRrVoY2sz7IG8kAKgrX/exXdht7ocP+HynH3J+PmabUhA X-Received: by 2002:a17:902:ff04:: with SMTP id f4mr304887plj.72.1566930875883; Tue, 27 Aug 2019 11:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566930875; cv=none; d=google.com; s=arc-20160816; b=KeaZcs3GNsZZfY24j4GkTWlJGp2v8A/AGFQHlfKtbQmMXFYv59CbcVsDE5Jrq39VWf YvJ6J7FI9QV0I4ANNl2lGm/urP+3hgiYmt+zZ5pxctaO1w3pLYkrTYM5IV4qVpOHoOCK T5PMWUzqM2NqH6jnOF2UIGbnA1S1JwsbYmD/1JoYAfzu9vigM3n5L57dy2YftU0d3d7v jN0PkbfkOxnmyJrNzKdS+6h5P6iSgxfD3HBrkuaQqWyBl1Gzb0VM4gxDsQyYw9/PoMu9 u8OT0IYoh7XV2gJZzOyzSbKa5pszuLrJyxeUaJ4pkHuy4nkpfc70kQxjIFZQc3MOtiHM qjqA== 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=C+7sRSxwREBbf4Ll/DO8csDExvS6mbaHTSSh9cCz+20=; b=vC6may5dIp3W3uSK7EEvhVObRBoSUrgsS0ZKJH/p4Kjmcr5j8fjeGGZSN8h7F8PHgT RiCUDcI4Utpy38DvfUe9IkMdvTWOYBFK4dBUGMnzjxpLRhwjWFTymQTZxRdkr24Cxmp9 RNAah4RijC6Wz1WLqn0FnN3g6aAeE/Ttww6D4uiflI7WWzGLTxvJh1IUy6Xox5zboT6I fv6pRB1hoAoPPTSH46CJYkwhi3Kt/Axm/XJCbH9CTS2xwb3PDRDOJqQ9svv3XHDuDDvk 6RmxrKITfnNUfpmEQeW55JrNOyA4Z5oNllatOmoRiWKXVNNcZwJvdbX+DxIY2Ej+Qpbe bK8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c73si14650814pfc.228.2019.08.27.11.34.19; Tue, 27 Aug 2019 11:34:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730814AbfH0SdZ (ORCPT + 99 others); Tue, 27 Aug 2019 14:33:25 -0400 Received: from smtprelay0123.hostedemail.com ([216.40.44.123]:41458 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730424AbfH0SdZ (ORCPT ); Tue, 27 Aug 2019 14:33:25 -0400 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave03.hostedemail.com (Postfix) with ESMTP id A828E1805A801; Tue, 27 Aug 2019 18:33:23 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id CEC63182CF666; Tue, 27 Aug 2019 18:33:22 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:599:800:960:973:981:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2197:2199:2393:2553:2559:2562:2691:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:7576:10004:10400:10848:11026:11232:11658:11914:12043:12297:12555:12679:12740:12760:12895:13069:13311:13357:13439:13548:14181:14659:14721:21080:21221:21451:21627:30054:30060:30070:30090:30091,0,RBL:23.242.196.136:@perches.com:.lbl8.mailshell.net-62.8.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: toad20_7493a051a5231 X-Filterd-Recvd-Size: 3368 Received: from XPS-9350 (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Tue, 27 Aug 2019 18:33:20 +0000 (UTC) Message-ID: Subject: Re: [PATCH] RDMA/siw: Fix compiler warnings on 32-bit due to u64/pointer abuse From: Joe Perches To: Geert Uytterhoeven , Al Viro , Andrew Morton Cc: David Laight , Bernard Metzler , Doug Ledford , Jason Gunthorpe , linux-rdma , Linux Kernel Mailing List Date: Tue, 27 Aug 2019 11:33:19 -0700 In-Reply-To: References: <20190819100526.13788-1-geert@linux-m68k.org> <581e7d79ed75484beb227672b2695ff14e1f1e34.camel@perches.com> <20190827174639.GT1131@ZenIV.linux.org.uk> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.32.1-2 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 Tue, 2019-08-27 at 19:59 +0200, Geert Uytterhoeven wrote: > On Tue, Aug 27, 2019 at 7:46 PM Al Viro wrote: > > On Tue, Aug 27, 2019 at 07:29:52PM +0200, Geert Uytterhoeven wrote: > > > On Tue, Aug 27, 2019 at 4:17 PM David Laight wrote: > > > > From: Geert Uytterhoeven > > > > > Sent: 19 August 2019 18:15 > > > > ... > > > > > > I think a cast to unsigned long is rather more common. > > > > > > > > > > > > uintptr_t is used ~1300 times in the kernel. > > > > > > I believe a cast to unsigned long is much more common. btw: apparently that's not true. This grep may be incomplete but it seems there are fewer kernel uses of a cast to unsigned long then pointer: $ git grep -P '\(\s*\w+(\s+\w+){0,3}(\s*\*)+\s*\)\s*\(\s*unsigned\s+long\s*\)'|wc -l 423 Maybe add a cast_to_ptr macro like #define cast_to_ptr(type, val) ((type)(uintptr_t)(val)) though that may not save any horizontal space and/or a checkpatch test like: --- scripts/checkpatch.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 287fe73688f0..4ec88bc53f2f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6281,6 +6281,15 @@ sub process { } } +# check for casts to pointer with intermediate casts to (unsigned long) not (uintptr_t) + if ($line =~ /\(\s*\w+(?:\s+\w+){0,3}(?:\s*\*){1,4}\s*\)\s*\(\s*unsigned\s+long\s*\)/) { + if (WARN("PREFER_UINTPTR_T", + "prefer intermediate cast to uintptr_t\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/(\(\s*\w+(?:\s+\w+){0,3}(?:\s*\*){1,4}\s*\))\s*\(\s*unsigned\s+long\s*\)/$1(uintptr_t)/; + } + } + # check for pointless casting of alloc functions if ($line =~ /\*\s*\)\s*$allocFunctions\b/) { WARN("UNNECESSARY_CASTS",