* [PATCH] checkpatch: fix spacing check for return with parentheses
@ 2020-11-17 20:13 Dwaipayan Ray
2020-11-18 20:54 ` Dwaipayan Ray
0 siblings, 1 reply; 2+ messages in thread
From: Dwaipayan Ray @ 2020-11-17 20:13 UTC (permalink / raw)
To: joe; +Cc: linux-kernel-mentees, dwaipayanray1, linux-kernel, lukas.bulwahn
The spacing check is unreachable for return statements
followed by an opening parentheses.
For example:
int foo(int bar, int baz)
{
return(bar+baz);
}
There should be an error emitted for a space between
return and the opening parentheses but checkpatch doesn't
emit one.
Fix the spacing check. Also add --fix option to
the check.
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
scripts/checkpatch.pl | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8da6cde20c68..07feeb3321e2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5176,10 +5176,13 @@ sub process {
if ($value =~ m/^\s*$FuncArg\s*(?:\?|$)/) {
ERROR("RETURN_PARENTHESES",
"return is not a function, parentheses are not required\n" . $herecurr);
+ } elsif ($spacing !~ /\s+/) {
+ if (ERROR("SPACING",
+ "space required before the open parenthesis '('\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\breturn\s*\(/return \(/;
+ }
}
- } elsif ($spacing !~ /\s+/) {
- ERROR("SPACING",
- "space required before the open parenthesis '('\n" . $herecurr);
}
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] checkpatch: fix spacing check for return with parentheses
2020-11-17 20:13 [PATCH] checkpatch: fix spacing check for return with parentheses Dwaipayan Ray
@ 2020-11-18 20:54 ` Dwaipayan Ray
0 siblings, 0 replies; 2+ messages in thread
From: Dwaipayan Ray @ 2020-11-18 20:54 UTC (permalink / raw)
To: Joe Perches; +Cc: linux-kernel-mentees, linux-kernel, Lukas Bulwahn
On Wed, Nov 18, 2020 at 1:43 AM Dwaipayan Ray <dwaipayanray1@gmail.com> wrote:
>
> The spacing check is unreachable for return statements
> followed by an opening parentheses.
> For example:
>
> int foo(int bar, int baz)
> {
> return(bar+baz);
> }
>
> There should be an error emitted for a space between
> return and the opening parentheses but checkpatch doesn't
> emit one.
>
> Fix the spacing check. Also add --fix option to
> the check.
>
> Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
> ---
> scripts/checkpatch.pl | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 8da6cde20c68..07feeb3321e2 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5176,10 +5176,13 @@ sub process {
> if ($value =~ m/^\s*$FuncArg\s*(?:\?|$)/) {
> ERROR("RETURN_PARENTHESES",
> "return is not a function, parentheses are not required\n" . $herecurr);
> + } elsif ($spacing !~ /\s+/) {
> + if (ERROR("SPACING",
> + "space required before the open parenthesis '('\n" . $herecurr) &&
> + $fix) {
> + $fixed[$fixlinenr] =~ s/\breturn\s*\(/return \(/;
> + }
> }
> - } elsif ($spacing !~ /\s+/) {
> - ERROR("SPACING",
> - "space required before the open parenthesis '('\n" . $herecurr);
> }
> }
>
> --
> 2.27.0
Sorry for the ping Joe. Just wanted to know if this got missed.
Thanks,
Dwaipayan.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-18 20:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 20:13 [PATCH] checkpatch: fix spacing check for return with parentheses Dwaipayan Ray
2020-11-18 20:54 ` Dwaipayan Ray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).