Skip to contentSkip to conversation

checkpatch.pl: recognize the #elif preprocessor directive

PATCH In review Benny Halevy 2 participants 2 messages Jan 1, 2008 – Jan 2, 2008 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch.pl: recognize the #elif preprocessor directive

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
	};
}
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +1 -1
index 579f50f..9911c17 100755
@@ -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';
#1 lore raw
Quoted 21 lines · Benny Halevy

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
	};
}
Quoted 1 line

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

-apw