[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9d8659fc8bc0729dd255c20234fb1a4210847ce9.camel@perches.com>
Date: Fri, 21 May 2021 07:45:23 -0700
From: Joe Perches <joe@...ches.com>
To: Joe Richey <joerichey94@...il.com>, trivial@...nel.org,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Joe Richey <joerichey@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Zhangfei Gao <zhangfei.gao@...aro.org>,
Zhou Wang <wangzhou1@...ilicon.com>,
Andy Whitcroft <apw@...onical.com>,
Dwaipayan Ray <dwaipayanray1@...il.com>,
Lukas Bulwahn <lukas.bulwahn@...il.com>,
Sasha Levin <sashal@...nel.org>,
"Chang S. Bae" <chang.seok.bae@...el.com>,
Andi Kleen <ak@...ux.intel.com>, Peter Xu <peterx@...hat.com>,
Lei Cao <lei.cao@...atus.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Zaibo Xu <xuzaibo@...wei.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-media@...r.kernel.org,
linux-accelerators@...ts.ozlabs.org
Subject: Re: [PATCH v2 7/7] checkpatch: suggest _BITULL() and _BITUL() for
UAPI headers
On Fri, 2021-05-21 at 01:58 -0700, Joe Richey wrote:
> From: Joe Richey <joerichey@...gle.com>
>
> 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 << <digit> that could be BIT(digit), it is not exported to uapi
> - if ($realfile !~ m@...clude/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 << <digit> 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@...lude/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.
Powered by blists - more mailing lists