summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2017-05-08 15:55:45 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-08 17:15:11 -0700
commitd9190e4e1a057ad55027cbefd1d21f6eae93fe0e (patch)
tree22798a9063b6ffa1aaac2c208e9c9a3e2c29dc4f /scripts
parenteb3a58de3ec4940fc6b2a9f810895d772a2a9794 (diff)
downloadlinux-stable-d9190e4e1a057ad55027cbefd1d21f6eae93fe0e.tar.gz
linux-stable-d9190e4e1a057ad55027cbefd1d21f6eae93fe0e.tar.bz2
linux-stable-d9190e4e1a057ad55027cbefd1d21f6eae93fe0e.zip
checkpatch: avoid suggesting struct definitions should be const
Many structs are generally used const and there is a known list of these structs. struct definitions should not be generally be declared const. Add a test for the lack of an open brace immediately after the struct to avoid definitions. This avoids the false positive "struct foo should normally be const" message only when the open brace is on the same line as the definition. Link: http://lkml.kernel.org/r/0dce709150d712e66f1b90b03827634b53b28085.1491845946.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Cc: Arthur Brainville <ybalrid@ybalrid.info> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl6
1 files changed, 3 insertions, 3 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 089c974aa3a5..3a1cb9d7474e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6090,11 +6090,11 @@ sub process {
}
# check for various structs that are normally const (ops, kgdb, device_tree)
+# and avoid what seem like struct definitions 'struct foo {'
if ($line !~ /\bconst\b/ &&
- $line =~ /\bstruct\s+($const_structs)\b/) {
+ $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
WARN("CONST_STRUCT",
- "struct $1 should normally be const\n" .
- $herecurr);
+ "struct $1 should normally be const\n" . $herecurr);
}
# use of NR_CPUS is usually wrong