Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1620508

[PATCH] checkpatch: Avoid suggesting struct definitions should be const

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject [PATCH] checkpatch: Avoid suggesting struct definitions should be const
Date 2017-04-10 19:50 +0200
Message-ID <tuLBU-3UP-11@gated-at.bofh.it> (permalink)
References <tumat-400-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 6 +++---
 1 file 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
-- 
2.10.0.rc2.1.g053435c

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] checkpatch: Avoid suggesting struct definitions should be const Joe Perches <joe@perches.com> - 2017-04-10 19:50 +0200
  Re: [PATCH] checkpatch: Avoid suggesting struct definitions should  be const "Arthur Brainville (Ybalrid)" <ybalrid@ybalrid.info> - 2017-04-10 21:00 +0200

csiph-web