* [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers @ 2020-06-10 20:33 Scott Branden 2020-06-10 21:09 ` Joe Perches 0 siblings, 1 reply; 7+ messages in thread From: Scott Branden @ 2020-06-10 20:33 UTC (permalink / raw) To: Andy Whitcroft, Joe Perches Cc: BCM Kernel Feedback, linux-kernel, Scott Branden Ignore CamelCase for inttypes.h for fixed integer types format specifiers. (ex. PRIx32 for uint32_t). Signed-off-by: Scott Branden <scott.branden@broadcom.com> --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 899e380782c0..9fa90457b270 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5157,6 +5157,8 @@ sub process { $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && #Ignore Page<foo> variants $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && #Ignore SI style variants like nS, mV and dB #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && -- 2.17.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers 2020-06-10 20:33 [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers Scott Branden @ 2020-06-10 21:09 ` Joe Perches 2020-06-10 21:48 ` Scott Branden 0 siblings, 1 reply; 7+ messages in thread From: Joe Perches @ 2020-06-10 21:09 UTC (permalink / raw) To: Scott Branden, Andy Whitcroft; +Cc: BCM Kernel Feedback, linux-kernel On Wed, 2020-06-10 at 13:33 -0700, Scott Branden wrote: > Ignore CamelCase for inttypes.h for fixed integer types format specifiers. > (ex. PRIx32 for uint32_t). Personally, I don't like those. > Signed-off-by: Scott Branden <scott.branden@broadcom.com> > --- > scripts/checkpatch.pl | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 899e380782c0..9fa90457b270 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5157,6 +5157,8 @@ sub process { > $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && > #Ignore Page<foo> variants > $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && > +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types > + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && > #Ignore SI style variants like nS, mV and dB > #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) > $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers 2020-06-10 21:09 ` Joe Perches @ 2020-06-10 21:48 ` Scott Branden 2020-06-10 22:22 ` Joe Perches 0 siblings, 1 reply; 7+ messages in thread From: Scott Branden @ 2020-06-10 21:48 UTC (permalink / raw) To: Joe Perches, Andy Whitcroft; +Cc: BCM Kernel Feedback, linux-kernel On 2020-06-10 2:09 p.m., Joe Perches wrote: > On Wed, 2020-06-10 at 13:33 -0700, Scott Branden wrote: >> Ignore CamelCase for inttypes.h for fixed integer types format specifiers. >> (ex. PRIx32 for uint32_t). > Personally, I don't like those. Checkpatch is run against a lot of code outside of the linux kernel but following linux coding style. There is nothing personal about this, they are the format specifiers in inttypes.h for fixed width types . > >> Signed-off-by: Scott Branden <scott.branden@broadcom.com> >> --- >> scripts/checkpatch.pl | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl >> index 899e380782c0..9fa90457b270 100755 >> --- a/scripts/checkpatch.pl >> +++ b/scripts/checkpatch.pl >> @@ -5157,6 +5157,8 @@ sub process { >> $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && >> #Ignore Page<foo> variants >> $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && >> +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types >> + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && >> #Ignore SI style variants like nS, mV and dB >> #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) >> $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers 2020-06-10 21:48 ` Scott Branden @ 2020-06-10 22:22 ` Joe Perches 2020-06-10 23:22 ` Scott Branden 2020-06-11 6:01 ` Scott Branden 0 siblings, 2 replies; 7+ messages in thread From: Joe Perches @ 2020-06-10 22:22 UTC (permalink / raw) To: Scott Branden, Andy Whitcroft; +Cc: BCM Kernel Feedback, linux-kernel On Wed, 2020-06-10 at 14:48 -0700, Scott Branden wrote: > > On 2020-06-10 2:09 p.m., Joe Perches wrote: > > On Wed, 2020-06-10 at 13:33 -0700, Scott Branden wrote: > > > Ignore CamelCase for inttypes.h for fixed integer types format specifiers. > > > (ex. PRIx32 for uint32_t). > > Personally, I don't like those. > Checkpatch is run against a lot of code outside of the linux kernel but > following linux coding style. I know. I don't have any strong feeling about this either. But _this_ checkpatch is specifically for the linux-kernel. I just don't want to encourage a bunch of uses of these somewhat useless defines internal to linux-kernel sources. > There is nothing personal about this, they are the format specifiers in > inttypes.h for fixed width types . True. It's impersonal to me too. > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > > > @@ -5157,6 +5157,8 @@ sub process { > > > $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && > > > #Ignore Page<foo> variants > > > $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && > > > +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types > > > + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && There are missing format specifiers. If this is done, the test should be against a variable Something like: our $inttype_format = qr{(?x: (?:PRI|SCN) [diouxX] (?:FAST|LEAST)? (?:8|16|32|64|MAX|PTR) }; btw: what about 24, 48, 96, 128 and 256? > > > #Ignore SI style variants like nS, mV and dB > > > #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) > > > $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers 2020-06-10 22:22 ` Joe Perches @ 2020-06-10 23:22 ` Scott Branden 2020-06-11 6:01 ` Scott Branden 1 sibling, 0 replies; 7+ messages in thread From: Scott Branden @ 2020-06-10 23:22 UTC (permalink / raw) To: Joe Perches, Andy Whitcroft; +Cc: BCM Kernel Feedback, linux-kernel Hi Joe, On 2020-06-10 3:22 p.m., Joe Perches wrote: > On Wed, 2020-06-10 at 14:48 -0700, Scott Branden wrote: >> On 2020-06-10 2:09 p.m., Joe Perches wrote: >>> On Wed, 2020-06-10 at 13:33 -0700, Scott Branden wrote: >>>> Ignore CamelCase for inttypes.h for fixed integer types format specifiers. >>>> (ex. PRIx32 for uint32_t). >>> Personally, I don't like those. >> Checkpatch is run against a lot of code outside of the linux kernel but >> following linux coding style. > I know. I don't have any strong feeling about this either. > > But _this_ checkpatch is specifically for the linux-kernel. > > I just don't want to encourage a bunch of uses of these > somewhat useless defines internal to linux-kernel sources. It is already used in various code in the linux-kernel tree for tools to work properly on different cpu architectures. Use of inttypes.h does have its place. So _this_ checkpatch shouldn't be complaining about them in the linux repo either? >> There is nothing personal about this, they are the format specifiers in >> inttypes.h for fixed width types . > True. It's impersonal to me too. > >>>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] >>>> @@ -5157,6 +5157,8 @@ sub process { >>>> $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && >>>> #Ignore Page<foo> variants >>>> $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && >>>> +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types >>>> + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && > There are missing format specifiers. > If this is done, the test should be against a variable > > Something like: > > our $inttype_format = qr{(?x: > (?:PRI|SCN) > [diouxX] > (?:FAST|LEAST)? > (?:8|16|32|64|MAX|PTR) > }; > > btw: what about 24, 48, 96, 128 and 256? > >>>> #Ignore SI style variants like nS, mV and dB >>>> #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) >>>> $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers 2020-06-10 22:22 ` Joe Perches 2020-06-10 23:22 ` Scott Branden @ 2020-06-11 6:01 ` Scott Branden 2020-06-11 6:32 ` Joe Perches 1 sibling, 1 reply; 7+ messages in thread From: Scott Branden @ 2020-06-11 6:01 UTC (permalink / raw) To: Joe Perches, Andy Whitcroft; +Cc: BCM Kernel Feedback, linux-kernel Hi Joe, A few questions about changes below. On 2020-06-10 3:22 p.m., Joe Perches wrote: > On Wed, 2020-06-10 at 14:48 -0700, Scott Branden wrote: >> On 2020-06-10 2:09 p.m., Joe Perches wrote: >>> On Wed, 2020-06-10 at 13:33 -0700, Scott Branden wrote: >>>> Ignore CamelCase for inttypes.h for fixed integer types format specifiers. >>>> (ex. PRIx32 for uint32_t). >>> Personally, I don't like those. >> Checkpatch is run against a lot of code outside of the linux kernel but >> following linux coding style. > I know. I don't have any strong feeling about this either. > > But _this_ checkpatch is specifically for the linux-kernel. > > I just don't want to encourage a bunch of uses of these > somewhat useless defines internal to linux-kernel sources. > >> There is nothing personal about this, they are the format specifiers in >> inttypes.h for fixed width types . > True. It's impersonal to me too. > >>>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] >>>> @@ -5157,6 +5157,8 @@ sub process { >>>> $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && >>>> #Ignore Page<foo> variants >>>> $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && >>>> +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types >>>> + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && > There are missing format specifiers. > If this is done, the test should be against a variable > > Something like: > > our $inttype_format = qr{(?x: > (?:PRI|SCN) > [diouxX] > (?:FAST|LEAST)? > (?:8|16|32|64|MAX|PTR) > }; I can try adding the "X" and FAST|LEAST. But I am not familiar enough with perl or the checkpatch script to understand what you mean by test should be against a variable vs what I have done. > btw: what about 24, 48, 96, 128 and 256? I can't find those values described for inttypes.h format specifiers. Where are you looking at those values from? > >>>> #Ignore SI style variants like nS, mV and dB >>>> #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) >>>> $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers 2020-06-11 6:01 ` Scott Branden @ 2020-06-11 6:32 ` Joe Perches 0 siblings, 0 replies; 7+ messages in thread From: Joe Perches @ 2020-06-11 6:32 UTC (permalink / raw) To: Scott Branden, Andy Whitcroft; +Cc: BCM Kernel Feedback, linux-kernel On Wed, 2020-06-10 at 23:01 -0700, Scott Branden wrote: > Hi Joe, > > A few questions about changes below. > > On 2020-06-10 3:22 p.m., Joe Perches wrote: > > On Wed, 2020-06-10 at 14:48 -0700, Scott Branden wrote: > > > On 2020-06-10 2:09 p.m., Joe Perches wrote: > > > > On Wed, 2020-06-10 at 13:33 -0700, Scott Branden wrote: > > > > > Ignore CamelCase for inttypes.h for fixed integer types format specifiers. > > > > > (ex. PRIx32 for uint32_t). > > > > Personally, I don't like those. > > > Checkpatch is run against a lot of code outside of the linux kernel but > > > following linux coding style. > > I know. I don't have any strong feeling about this either. > > > > But _this_ checkpatch is specifically for the linux-kernel. > > > > I just don't want to encourage a bunch of uses of these > > somewhat useless defines internal to linux-kernel sources. > > > > > There is nothing personal about this, they are the format specifiers in > > > inttypes.h for fixed width types . > > True. It's impersonal to me too. > > > > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > [] > > > > > @@ -5157,6 +5157,8 @@ sub process { > > > > > $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && > > > > > #Ignore Page<foo> variants > > > > > $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && > > > > > +#Ignore inttypes.h scanf/printf format specifiers for fixed size integer types > > > > > + $var !~ /^(?:PRI|SCN)[dxoui](8|16|32|64|PTR|MAX)?$/ && > > There are missing format specifiers. > > If this is done, the test should be against a variable > > > > Something like: > > > > our $inttype_format = qr{(?x: > > (?:PRI|SCN) > > [diouxX] > > (?:FAST|LEAST)? > > (?:8|16|32|64|MAX|PTR) > > }; > I can try adding the "X" and FAST|LEAST. > But I am not familiar enough with perl or the checkpatch script to > understand > what you mean by test should be against a variable vs what I have done. > > btw: what about 24, 48, 96, 128 and 256? > I can't find those values described for inttypes.h format specifiers. There are others outside of linux. http://cmod.gforge.inria.fr/doxygen/group__POSIX%E2%88%B7std%E2%88%B7inttypes%E2%88%B7__Snippet.html > Where are you looking at those values from? > > > > > #Ignore SI style variants like nS, mV and dB > > > > > #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) > > > > > $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && Like this: --- scripts/checkpatch.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 524df88f9364..112ea055eba1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -565,6 +565,14 @@ our $C90_int_types = qr{(?x: (?:(?:un)?signed\s+)?int )}; +# inttype.h formats +our $inttype_formats = qr{(?x: + (?:PRI|SCN) + [diouxX] + (?:FAST|LEAST)? + (?:8|16|32|64|MAX|PTR) +)}; + our @typeListFile = (); our @typeListWithAttr = ( @typeList, @@ -5151,7 +5159,8 @@ sub process { #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE) $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ && #Ignore some three character SI units explicitly, like MiB and KHz - $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) { + $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/ && + $var !~ /^$inttype_formats$/) { while ($var =~ m{($Ident)}g) { my $word = $1; next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/); ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-06-11 6:32 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-06-10 20:33 [PATCH] checkpatch: ignore CamelCase for inttypes.h format specifiers Scott Branden 2020-06-10 21:09 ` Joe Perches 2020-06-10 21:48 ` Scott Branden 2020-06-10 22:22 ` Joe Perches 2020-06-10 23:22 ` Scott Branden 2020-06-11 6:01 ` Scott Branden 2020-06-11 6:32 ` Joe Perches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®