All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning
       [not found] <CGME20210907114641epcas5p1d96f31466bd11399e98305865e05fc7e@epcas5p1.samsung.com>
@ 2021-09-07 11:46 ` Maninder Singh
  0 siblings, 0 replies; only message in thread
From: Maninder Singh @ 2021-09-07 11:46 UTC (permalink / raw)
  To: apw, joe, dwaipayanray1, lukas.bulwahn
  Cc: linux-kernel, a.sahrawat, Maninder Singh, Vaneet Narang

printk_deferred and printk_deferred_once require LOGELVEL in argument,
but checkpatch.pl reports it as warning:

WARNING: Possible unnecessary KERN_ALERT
printk_deferred(KERN_ALERT "checking deferred\n");

As suggested by Andy, made 2 functions from logFunctions
1. logFunctions: with all checks
2. logFunctionsCore: without printk(?:_ratelimited|_once|_deferred_once|_deferred)
   checks

Call logFunctionsCore instead of logFunctions for checking of LOGLEVEL,
which will exclude checking of printk(?:_ratelimited|_once|_deferred_once|_deferred).

This way, there is no need to maintain same stanza at places for removing
printk flavours.

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
---
v1 -> v2: made 2 functions to remove _deferred_once also
	as suggested by Andy Whitcroft.

 scripts/checkpatch.pl | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 161ce7fe5d1e..ebad442f29a0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -559,8 +559,7 @@ our $typeTypedefs = qr{(?x:
 
 our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};
 
-our $logFunctions = qr{(?x:
-	printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
+our $logFunctionsCore = qr{(?x:
 	(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
 	TP_printk|
 	WARN(?:_RATELIMIT|_ONCE|)|
@@ -569,6 +568,11 @@ our $logFunctions = qr{(?x:
 	seq_vprintf|seq_printf|seq_puts
 )};
 
+our $logFunctions = qr{(?x:
+	printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
+	$logFunctionsCore
+)};
+
 our $allocFunctions = qr{(?x:
 	(?:(?:devm_)?
 		(?:kv|k|v)[czm]alloc(?:_array)?(?:_node)? |
@@ -6252,8 +6256,7 @@ sub process {
 		}
 
 # check for logging functions with KERN_<LEVEL>
-		if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
-		    $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
+		if ($line =~ /\b$logFunctionsCore\s*\(.*\b(KERN_[A-Z]+)\b/) {
 			my $level = $1;
 			if (WARN("UNNECESSARY_KERN_LEVEL",
 				 "Possible unnecessary $level\n" . $herecurr) &&
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-07 11:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210907114641epcas5p1d96f31466bd11399e98305865e05fc7e@epcas5p1.samsung.com>
2021-09-07 11:46 ` [PATCH v2] scripts/checkpatch.pl: remove _deferred and _deferred_once false warning Maninder Singh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.