History

checkpatch: allow parentheses on return for comparisons

It seems to be a common idiom to include braces on conditionals in all contexts including return. Allow this exception to the return is not a function checks. Reported by Kay Sievers.

Andy Whitcroft committed 17 years ago

Commit 86f9d051 parent 1e855721 file · +3 −2Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+3−2
@@ -127,6 +127,7 @@ our $Lval = qr{$Ident(?:$Member)*}; · 126 unmodified lines
127127
128128 our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*};
129129 our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
130+our $Compare = qr{<=|>=|==|!=|<|>};
130131 our $Operators = qr{
131132 <=|>=|==|!=|
132133 =>|->|<<|>>|<|>|!|~|
@@ -1983,9 +1984,9 @@ sub process { · 1850 unmodified lines
19831984 my $spacing = $1;
19841985 my $value = $2;
19851986
1986− # Flatten any parentheses and braces
1987+ # Flatten any parentheses
19871988 $value =~ s/\)\(/\) \(/g;
1988− while ($value =~ s/\([^\(\)]*\)/1/) {
1989+ while ($value !~ /(?:$Ident|-?$Constant)\s*$Compare\s*(?:$Ident|-?$Constant)/ && $value =~ s/\([^\(\)]*\)/1/) {
19891990 }
19901991
19911992 if ($value =~ /^(?:$Ident|-?$Constant)$/) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t