Skip to contentSkip to conversation

checkpatch: add check for the buggy while_each_thread()

PATCH Superseded Sergey Dyasly 2 participants 3 messages Jan 18, 2015 – Jan 21, 2015 Checkpatch

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: add check for the buggy while_each_thread()

Now it's preferable to use for_each_thread() instead of while_each_thread(). Add a check to checkpatch.pl in order to prevent any new usages of the buggy while_each_thread() when possible.

Cc Oleg Nesterov <[email protected]>
Cc Andy Whitcroft <[email protected]>
Cc Joe Perches <[email protected]>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index f0bb6d6..0c5cc0b 100755
@@ -3255,6 +3255,12 @@ sub process {
 			     "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
 		}
 
+# Check for the buggy while_each_thread()
+		if ($line =~ /\bwhile_each_thread\(/) {
+			WARN("WHILE_EACH_THREAD",
+			     "Prefer to use for_each_thread() instead of the buggy while_each_thread(). See commit 0c740d0afc3bff0a097ad03a1c8df92757516f5c for details.\n" . $herecurr);
+		}
+
 # function brace can't be on same line, except for #defines of do while,
 # or if closed on same line
 		if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and
Signature · 1 line
2.2.2
maintainer
#1 lore raw
Quoted 3 lines · Sergey Dyasly

Now it's preferable to use for_each_thread() instead of while_each_thread(). Add a check to checkpatch.pl in order to prevent any new usages of the buggy while_each_thread() when possible.

[]

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3259

Quoted 6 lines
scripts/checkpatch.pl +2 -0
@@ -3255,6 +3255,12 @@ sub process {
 			     "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
 		}
 
+# Check for the buggy while_each_thread()
+		if ($line =~ /\bwhile_each_thread\(/) {
	\bwhile_each_thread\s*\(

or maybe
\bwhile_each_thread\b

scripts/checkpatch.pl sub process { · line 3261

Quoted 2 lines
scripts/checkpatch.pl +2 -0
+			WARN("WHILE_EACH_THREAD",
+			     "Prefer to use for_each_thread() instead of the buggy while_each_thread(). See commit 0c740d0afc3bff0a097ad03a1c8df92757516f5c for details.\n" . $herecurr);

Pretty long commit id, 12 is probably enough.

#2 lore raw
Quoted 15 lines · On Sun, 18 Jan 2015 17:27:33 -0800 Joe Perches <[email protected]> wrote:
Quoted 3 lines · Sergey Dyasly

Now it's preferable to use for_each_thread() instead of while_each_thread(). Add a check to checkpatch.pl in order to prevent any new usages of the buggy while_each_thread() when possible.

[]

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl sub process { · line 3259

Quoted 6 lines
scripts/checkpatch.pl +2 -0
@@ -3255,6 +3255,12 @@ sub process {
 			     "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
 		}
 
+# Check for the buggy while_each_thread()
+		if ($line =~ /\bwhile_each_thread\(/) {
	\bwhile_each_thread\s*\(
Quoted 7 lines

or maybe
\bwhile_each_thread\b

scripts/checkpatch.pl sub process { · line 3261

Quoted 2 lines
scripts/checkpatch.pl +2 -0
+			WARN("WHILE_EACH_THREAD",
+			     "Prefer to use for_each_thread() instead of the buggy while_each_thread(). See commit 0c740d0afc3bff0a097ad03a1c8df92757516f5c for details.\n" . $herecurr);

Pretty long commit id, 12 is probably enough.

"\bwhile_each_thread\s*\(" and 12-digit commit id sound reasonable, thanks. I'll update the patch.

Signature · 1 line
Sergey Dyasly <[email protected]>