2015-04-07 03:37:05

by Sam Bobroff

[permalink] [raw]
Subject: [PATCH 1/1] checkpatch: improve operator spacing check

Code such as:
x = timercmp(&now, &end, <);
Will currently trigger a checkpatch error. e.g.

ERROR: spaces required around that '<'

This is because the "Ignore operators passed as parameters" check
looks only for a comma following the operator. Improve the check by
also looking for a close parenthesis.

Signed-off-by: Sam Bobroff <[email protected]>
---

scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d124359..f65c4de 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3565,7 +3565,7 @@ sub process {

# Ignore operators passed as parameters.
if ($op_type ne 'V' &&
- $ca =~ /\s$/ && $cc =~ /^\s*,/) {
+ $ca =~ /\s$/ && $cc =~ /^\s*[,\)]/) {

# # Ignore comments
# } elsif ($op =~ /^$;+$/) {
--
1.7.10.4


2015-04-07 03:52:54

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 1/1] checkpatch: improve operator spacing check

On Tue, 2015-04-07 at 13:36 +1000, Sam Bobroff wrote:
> Code such as:
> x = timercmp(&now, &end, <);
> Will currently trigger a checkpatch error. e.g.
> ERROR: spaces required around that '<'
>
> This is because the "Ignore operators passed as parameters" check
> looks only for a comma following the operator. Improve the check by
> also looking for a close parenthesis.
>
> Signed-off-by: Sam Bobroff <[email protected]>

Seems sensible, thanks.

> ---
>
> scripts/checkpatch.pl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d124359..f65c4de 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3565,7 +3565,7 @@ sub process {
>
> # Ignore operators passed as parameters.
> if ($op_type ne 'V' &&
> - $ca =~ /\s$/ && $cc =~ /^\s*,/) {
> + $ca =~ /\s$/ && $cc =~ /^\s*[,\)]/) {
>
> # # Ignore comments
> # } elsif ($op =~ /^$;+$/) {