Skip to contentSkip to conversation

+ checkpatch-improve-no-space-after-cast-test.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Jun 11, 2013 Checkpatch

lore
Share & tools
lore
#0 lore raw

Subject: + checkpatch-improve-no-space-after-cast-test.patch added to -mm tree
To: [email protected]
From: [email protected]
Date: Tue, 11 Jun 2013 15:50:42 -0700

The patch titled
Subject: checkpatch: improve "no space after cast" test
has been added to the -mm tree. Its filename is
checkpatch-improve-no-space-after-cast-test.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Joe Perches <[email protected]>
Subject: checkpatch: improve "no space after cast" test

Some false positives exist on this test.

For instance:

	*va_arg(args, signed char *) = val.s;
or
	memset(foo, 0, sizeof(struct bar *) * baz));

Ignore lines that have an arithmetic operator or assignment after what appears to be a cast to a pointer "(foo *)".

Add $Arithmetic convenience variable.

---

 scripts/checkpatch.pl |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-improve-no-space-after-cast-test +3 -2
diff -puN scripts/checkpatch.pl~checkpatch-improve-no-space-after-cast-test scripts/checkpatch.pl
@@ -241,10 +241,11 @@ our $Float	= qr{$Float_hex|$Float_dec|$F
 our $Constant	= qr{$Float|$Binary|$Hex|$Int};
 our $Assignment	= qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
 our $Compare    = qr{<=|>=|==|!=|<|>};
+our $Arithmetic = qr{\+|-|\*|\/|%};
 our $Operators	= qr{
 			<=|>=|==|!=|
 			=>|->|<<|>>|<|>|!|~|
-			&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%
+			&&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
 		  }x;
 
 our $NonptrType;
@@ -1885,7 +1886,7 @@ sub process {
 			}
 		}
 
-		if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) {
+		if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
 			CHK("SPACING",
 			    "No space is necessary after a cast\n" . $hereprev);
 		}

_

Patches currently in -mm which might be from [email protected] are

linux-next.patch checkpatch-change-camelcase-test-and-make-it-strict.patch checkpatch-warn-when-using-gccs-binary-constant-extension.patch checkpatch-add-strict-preference-for-p-=-kmallocsizeofp.patch checkpatch-remove-quote-from-camelcase-test.patch checkpatch-improve-network-block-comment-test-and-message.patch checkpatch-warn-when-networking-block-comment-lines-dont-start-with.patch checkpatch-warn-on-comparisons-to-jiffies.patch checkpatch-warn-on-comparisons-to-get_jiffies_64.patch checkpatch-reduce-false-positive-rate-of-complex-macros.patch checkpatch-add-a-placeholder-to-check-blank-lines-before-declarations.patch checkpatch-dont-warn-on-blank-lines-before-after-braces-as-often.patch checkpatch-add-a-strict-test-for-comparison-to-true-false.patch checkpatch-improve-no-space-after-cast-test.patch checkpatch-create-an-experimental-fix-option-to-correct-patches.patch checkpatch-move-test-for-space-before-semicolon-after-operator-spacing.patch