[PATCH] checkpatch.pl: recognize the #elif preprocessor directive

Previous thread: [Patch 0/8] Remove 'TOPDIR' from Makefiles by WANG Cong on Tuesday, January 1, 2008 - 3:13 am. (50 messages)

Next thread: Linux 2.4.36 released by Willy Tarreau on Tuesday, January 1, 2008 - 8:58 am. (1 message)
To: Andy Whitcroft <apw@...>
Cc: lkml <linux-kernel@...>, Joel Schopp <jschopp@...>
Date: Tuesday, January 1, 2008 - 6:12 am

checkpatch.pl does not recognize #elif as a preprocessor directive
causing it to print bogus errors for, e.g.:
ERROR: need consistent spacing around '&' (ctx:WxV)
when the operator is not recognized as unary in this context.

for example:

void foo(void)
{
int x, y, z;
void *p[1] = {
#if defined(X)
&x
#elif defined(Y)
&y
#else
&z
#endif
};
}

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
---
scripts/checkpatch.pl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 579f50f..9911c17 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -534,7 +534,7 @@ sub annotate_values {
$preprocessor = 1;
$paren_type[$paren] = 'N';

- } elsif ($cur =~ /^(#\s*(?:ifdef|ifndef|if|else|endif))/o) {
+ } elsif ($cur =~ /^(#\s*(?:ifdef|ifndef|if|else|elif|endif))/o) {
print "PRE($1)\n" if ($debug);
$preprocessor = 1;
$type = 'N';

--

To: Benny Halevy <bhalevy@...>
Cc: lkml <linux-kernel@...>, Joel Schopp <jschopp@...>
Date: Wednesday, January 2, 2008 - 5:49 am

Yes, thanks; good catch. Commited this and added tests for it.
Will be in 0.13 which is imminent.

-apw
--

Previous thread: [Patch 0/8] Remove 'TOPDIR' from Makefiles by WANG Cong on Tuesday, January 1, 2008 - 3:13 am. (50 messages)

Next thread: Linux 2.4.36 released by Willy Tarreau on Tuesday, January 1, 2008 - 8:58 am. (1 message)