public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: suggest spaces around binary operators in strict mode
@ 2011-07-08 21:41 Pavel Roskin
  2011-07-08 23:01 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Roskin @ 2011-07-08 21:41 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: linux-kernel

Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 scripts/checkpatch.pl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b0aa2c6..9431ada 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2167,6 +2167,8 @@ sub process {
 					if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
 						ERROR("need consistent spacing around '$op' $at\n" .
 							$hereptr);
+					} elsif ($ctx =~ /[^WCE]x[^WCE]/) {
+						CHK("spaces suggested around '$op' $at\n" . $hereptr);
 					}
 
 				# A colon needs no spaces before when it is

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] checkpatch: suggest spaces around binary operators in strict mode
  2011-07-08 21:41 [PATCH] checkpatch: suggest spaces around binary operators in strict mode Pavel Roskin
@ 2011-07-08 23:01 ` Joe Perches
  2011-07-09  1:08   ` Pavel Roskin
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2011-07-08 23:01 UTC (permalink / raw)
  To: Pavel Roskin; +Cc: Andy Whitcroft, linux-kernel

On Fri, 2011-07-08 at 17:41 -0400, Pavel Roskin wrote:
> Signed-off-by: Pavel Roskin <proski@gnu.org>
> ---
>  scripts/checkpatch.pl |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index b0aa2c6..9431ada 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2167,6 +2167,8 @@ sub process {
>  					if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
>  						ERROR("need consistent spacing around '$op' $at\n" .
>  							$hereptr);
> +					} elsif ($ctx =~ /[^WCE]x[^WCE]/) {
> +						CHK("spaces suggested around '$op' $at\n" . $hereptr);

Hey Pavel.

This should probably not be an elsif but
a standalone test.

Also, there's an upcoming patch in mm that
classifies all output ERROR/WARN/CHK types.

This one should be "SPACING".

https://lkml.org/lkml/2011/6/21/256

http://userweb.kernel.org/~akpm/mmotm/broken-out/checkpatchpl-add-ability-to-ignore-various-messages.patch



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] checkpatch: suggest spaces around binary operators in strict mode
  2011-07-08 23:01 ` Joe Perches
@ 2011-07-09  1:08   ` Pavel Roskin
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Roskin @ 2011-07-09  1:08 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel

On 07/08/2011 07:01 PM, Joe Perches wrote:
> On Fri, 2011-07-08 at 17:41 -0400, Pavel Roskin wrote:
>> Signed-off-by: Pavel Roskin<proski@gnu.org>
>> ---
>>   scripts/checkpatch.pl |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index b0aa2c6..9431ada 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -2167,6 +2167,8 @@ sub process {
>>   					if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
>>   						ERROR("need consistent spacing around '$op' $at\n" .
>>   							$hereptr);
>> +					} elsif ($ctx =~ /[^WCE]x[^WCE]/) {
>> +						CHK("spaces suggested around '$op' $at\n" . $hereptr);
>
> Hey Pavel.
>
> This should probably not be an elsif but
> a standalone test.

Maybe.  I just tried to minimize the changes.  I think all of the 
operators in the condition above the lines I changed need spaces around 
them, so I decided to reuse the code block.

Spaces around binary operands are pretty standard.  scripts/Lindent 
would add them.

I understand that not everybody wants that rule enforced, so I used a 
nicely worded warning and enabled it only in the strict mode.  That was 
done to avoid sparking a flamewar about formatting.

There are some cases when missing spaces are palatable, in particular 
with "|", which is thin.  So this may be OK:

(high_id << 8)|(low_id & 0xff)

But I've seen checkpatch ignore stuff like this:

ah->ah_gain.g_current-ah->ah_gain.g_f_corr

And that is just horrible on the eyes.  I want checkpatch to catch that.

> Also, there's an upcoming patch in mm that
> classifies all output ERROR/WARN/CHK types.
>
> This one should be "SPACING".

OK, please keep my suggestion in mind.

-- 
Regards,
Pavel Roskin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-09  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-08 21:41 [PATCH] checkpatch: suggest spaces around binary operators in strict mode Pavel Roskin
2011-07-08 23:01 ` Joe Perches
2011-07-09  1:08   ` Pavel Roskin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox