From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30EF2C47078 for ; Fri, 21 May 2021 14:51:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C16F61244 for ; Fri, 21 May 2021 14:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237117AbhEUOwc (ORCPT ); Fri, 21 May 2021 10:52:32 -0400 Received: from smtprelay0094.hostedemail.com ([216.40.44.94]:32824 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232057AbhEUOwc (ORCPT ); Fri, 21 May 2021 10:52:32 -0400 X-Greylist: delayed 331 seconds by postgrey-1.27 at vger.kernel.org; Fri, 21 May 2021 10:52:32 EDT Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave04.hostedemail.com (Postfix) with ESMTP id CDFDB18005A65; Fri, 21 May 2021 14:45:44 +0000 (UTC) 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-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: kvm@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.