Skip to contentSkip to conversation

checkpatch: forward declarations fix

PATCH Joe Korty 1 participant 1 message May 2, 2012 Checkpatch

lore
Share & tools
lore

Joe Korty

author
#0 lore raw

Allow forward declarations of the form:

	struct file_operations;

to exist without requiring the preceeding 'const'. In any case C does not allow 'const' on forward declarations.

scripts/checkpatch.pl +5 -3
Index: linux/scripts/checkpatch.pl
===================================================================
@@ -3411,9 +3411,11 @@
 				wd_ops}x;
 		if ($line !~ /\bconst\b/ &&
 		    $line =~ /\bstruct\s+($struct_ops)\b/) {
-			WARN("CONST_STRUCT",
-			     "struct $1 should normally be const\n" .
-				$herecurr);
+			if ($line !~ /struct\s+($struct_ops);/) {
+				WARN("CONST_STRUCT",
+				     "struct $1 should normally be const\n" .
+					$herecurr);
+			}
 		}
 
 # use of NR_CPUS is usually wrong