Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1400307pxj; Fri, 21 May 2021 13:19:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXMcp5klB1FfkoRAiBuUOW9vQvBvubER/am9YdPuxgKAjqKbL2J5yg2SKGdLuB37FrbsPY X-Received: by 2002:a17:907:37b:: with SMTP id rs27mr12348296ejb.287.1621628375459; Fri, 21 May 2021 13:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628375; cv=none; d=google.com; s=arc-20160816; b=RTBVmJ0P/7tmqPymO/OqlkiKcmF1rxIFzFlsK9No+a65tGrGcF2sEzLFFN9oHzXlSU hUa2xWMI2qmqGP2Ydr7Cuib94sQaaT5ZvFh2AkVE46RuzDqpvnEbfl2u+WO2o0ozJmFS 4DaXFLOtaqkAFVkel4STIil4YysEmw70mg1+mfY2nUU4eaP9rrNNqMTaT3Ih0KIocTj4 YNiFsd3C5vCyGFZmRFc5JT4AmDIDRoXzq4JKtbtCCkas5tYKKp2g6bQkkKjGp2OlOYO9 PDFHEgVzVsG0qwe/aZbD2vkABVxMOI/knpoEVyRuge3Jsma20MpgdQwzF1luHBUt/tnq nMkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=Se9UoClVFqKZKcFRcttJrMF4e3WdLsgwZ+f+7u7mSFc=; b=RFM1ivW8u2AlvI95yEf0/FJu3vBx0sOFmQq31mwYV+z6+W1c1+6tXwus7aUNXH6ayz 2QYVN5ZH3OJ31bqul19qkwb5y0dOMViSYs2pRYpp4iXx1vCNSrbDWvwBgy8AVWmg9fO+ MpHwKUei1HW7KrmLzY/e9qXCkF1ml/mPD6/xqAhpvrhoNFDy+cxcni5jTvyjLAM836wk Aq2p/ZaDXNG1KuFkIPmqU59YROqNRPp8ofGY4oA7ZiLyYhAh9K2UQ5KMlodQeI2JdR1A hvVREZmeG/FXiJEiBjh6BY3s1zozDB7KtynHCSI44ckrydwPhigIJimk8qut1nB/YKrY eY+Q== 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 jw24si6101485ejc.701.2021.05.21.13.19.12; Fri, 21 May 2021 13:19:35 -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 S236891AbhEUOrJ (ORCPT + 99 others); Fri, 21 May 2021 10:47:09 -0400 Received: from smtprelay0065.hostedemail.com ([216.40.44.65]:59128 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236911AbhEUOrE (ORCPT ); Fri, 21 May 2021 10:47:04 -0400 Received: from omf03.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id BE128D218; Fri, 21 May 2021 14:45:37 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA id 74ED713D95; Fri, 21 May 2021 14:45:25 +0000 (UTC) Message-ID: <9d8659fc8bc0729dd255c20234fb1a4210847ce9.camel@perches.com> Subject: Re: [PATCH v2 7/7] checkpatch: suggest _BITULL() and _BITUL() for UAPI headers From: Joe Perches To: Joe Richey , trivial@kernel.org, Andrew Morton Cc: Joe Richey , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Paolo Bonzini , Mark Rutland , Lorenzo Pieralisi , Mauro Carvalho Chehab , Zhangfei Gao , Zhou Wang , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Sasha Levin , "Chang S. Bae" , Andi Kleen , Peter Xu , Lei Cao , Ulf Hansson , Daniel Lezcano , "Rafael J. Wysocki" , Jean-Philippe Brucker , Zaibo Xu , Greg Kroah-Hartman , Hans Verkuil , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-accelerators@lists.ozlabs.org Date: Fri, 21 May 2021 07:45:23 -0700 In-Reply-To: <20210521085849.37676-8-joerichey94@gmail.com> References: <20210520104343.317119-1-joerichey94@gmail.com> <20210521085849.37676-1-joerichey94@gmail.com> <20210521085849.37676-8-joerichey94@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.40 X-Stat-Signature: qn5g8k3jtqoj4kuui4tsua91y1s1o8zk X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 74ED713D95 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/+/DrG8NEx+1xztaZeFya67FR2cEwvbqU= X-HE-Tag: 1621608325-902736 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-05-21 at 01:58 -0700, Joe Richey wrote: > From: Joe Richey > > Instead of just ignoring UAPI headers, reccomend the UAPI compatible > macros if a user adds something that looks like (1 << n). Normal kernel > code will continue to get BIT_ULL() and BIT() reccomended. > > This change also modifies the $realfile regex to match headers that have > "include/uapi" anywhere in their path so paths like: > ????tools/include/uapi/linux/kvm.h > ????arch/x86/include/uapi/asm/hwcap2.h > get recognized as UAPI headers. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -7020,15 +7020,17 @@ sub process { > ? } > ? } > ? > > -# check for #defines like: 1 << that could be BIT(digit), it is not exported to uapi > - if ($realfile !~ m@^include/uapi/@ && > - $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) { > - my $ull = ""; > - $ull = "_ULL" if (defined($1) && $1 =~ /ll/i); > +# check for #defines like: 1 << that could be BIT(digit) or similar > + if ($line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) { > + my $ull = (defined($1) && $1 =~ /ll/i); > + my $macroname = $ull ? "BIT_ULL" : "BIT"; > + if ($realfile =~ m@include/uapi/@) { Likely better with \b if ($realfile =~ m@\binclude/uapi/@) { > + $macroname = $ull ? "_BITULL" : "_BITUL"; > + } > ? if (CHK("BIT_MACRO", > - "Prefer using the BIT$ull macro\n" . $herecurr) && > + "Prefer using the $macroname macro\n" . $herecurr) && > ? $fix) { > - $fixed[$fixlinenr] =~ s/\(?\s*1\s*[ulUL]*\s*<<\s*(\d+|$Ident)\s*\)?/BIT${ull}($1)/; > + $fixed[$fixlinenr] =~ s/\(?\s*1\s*[ulUL]*\s*<<\s*(\d+|$Ident)\s*\)?/${macroname}($1)/; Doesn't need braces $fixed[$fixlinenr] =~ s/\(?\s*1\s*[ulUL]*\s*<<\s*(\d+|$Ident)\s*\)?/$macroname($1)/; Otherwise, fine by me.