The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] scripts/checkpatch.pl - don't check for const structs if list is empty
@ 2019-09-03 10:38 Valdis Klētnieks
  2019-09-03 16:05 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Valdis Klētnieks @ 2019-09-03 10:38 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches; +Cc: Pablo Pellecchia, linux-kernel

If the list of structures we expect to be const is empty (due to file permissions,
or the file being empty, etc), we get odd complaints about structures:

[/usr/src/linux-next] scripts/checkpatch.pl -f drivers/staging/netlogic/platform_net.h
No structs that should be const will be found - file '/usr/src/linux-next/scripts/const_structs.checkpatch': Permission denied
WARNING: struct  should normally be const
#9: FILE: drivers/staging/netlogic/platform_net.h:9:
+struct xlr_net_data {

WARNING: struct  should normally be const
#20: FILE: drivers/staging/netlogic/platform_net.h:20:
+	struct xlr_fmn_info *gmac_fmn_info;

total: 0 errors, 2 warnings, 0 checks, 21 lines checked

Fix it so that it actually *obeys* what it said about not finding structures.

Reported-by: Pablo Pellecchia <pablo9891@gmail.com>
Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f4b6127ff469..103c67665f61 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6497,7 +6497,7 @@ 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/ &&
+		if ($line !~ /\bconst\b/ && $const_structs ne "" &&
 		    $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
 			WARN("CONST_STRUCT",
 			     "struct $1 should normally be const\n" . $herecurr);


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-03 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-03 10:38 [PATCH] scripts/checkpatch.pl - don't check for const structs if list is empty Valdis Klētnieks
2019-09-03 16:05 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox