mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch added to -mm tree
@ 2020-12-10  0:02 akpm
  2020-12-11 17:53 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2020-12-10  0:02 UTC (permalink / raw)
  To: mm-commits, joe


The patch titled
     Subject: checkpatch: add printk_once and printk_ratelimit to prefer pr_<level> warning
has been added to the -mm tree.  Its filename is
     checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Joe Perches <joe@perches.com>
Subject: checkpatch: add printk_once and printk_ratelimit to prefer pr_<level> warning

Add the _once and _ratelimited variants to the test for
printk(KERN_<LEVEL> that should prefer pr_<level>.

Miscellanea:

o Add comment description for the conversions

Link: https://lkml.kernel.org/r/993b72b2ef91a57c5e725b52971ce3fd31375061.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 scripts/checkpatch.pl |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

--- a/scripts/checkpatch.pl~checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning
+++ a/scripts/checkpatch.pl
@@ -4543,16 +4543,22 @@ sub process {
 			     "printk() should include KERN_<LEVEL> facility level\n" . $herecurr);
 		}
 
-		if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
-			my $orig = $1;
+# prefer variants of (subsystem|netdev|dev|pr)_<level> to printk(KERN_<LEVEL>
+		if ($line =~ /\b(printk(_once|_ratelimited)?)\s*\(\s*KERN_([A-Z]+)/) {
+			my $printk = $1;
+			my $modifier = $2;
+			my $orig = $3;
 			my $level = lc($orig);
 			$level = "warn" if ($level eq "warning");
 			my $level2 = $level;
 			$level2 = "dbg" if ($level eq "debug");
+			$level .= $modifier;
+			$level2 .= $modifier;
 			WARN("PREFER_PR_LEVEL",
-			     "Prefer [subsystem eg: netdev]_$level2([subsystem]dev, ... then dev_$level2(dev, ... then pr_$level(...  to printk(KERN_$orig ...\n" . $herecurr);
+			     "Prefer [subsystem eg: netdev]_$level2([subsystem]dev, ... then dev_$level2(dev, ... then pr_$level(...  to $printk(KERN_$orig ...\n" . $herecurr);
 		}
 
+# prefer dev_<level> to dev_printk(KERN_<LEVEL>
 		if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
 			my $orig = $1;
 			my $level = lc($orig);
_

Patches currently in -mm which might be from joe@perches.com are

mm-zswap-make-struct-kernel_param_ops-definitions-const.patch
mm-use-sysfs_emit-for-struct-kobject-uses.patch
mm-huge_memory-convert-remaining-use-of-sprintf-to-sysfs_emit-and-neatening.patch
mm-backing-dev-use-sysfs_emit-in-macro-defining-functions.patch
mm-shmem-convert-shmem_enabled_show-to-use-sysfs_emit_at.patch
mm-slub-convert-sysfs-sprintf-family-to-sysfs_emit-sysfs_emit_at.patch
checkpatch-prefer-static-const-declarations.patch
checkpatch-allow-fix-removal-of-unnecessary-break-statements.patch
checkpatch-update-__attribute__sectionname-quote-removal.patch
checkpatch-update-__attribute__sectionname-quote-removal-v2.patch
checkpatch-add-__alias-and-__weak-to-suggested-__attribute__-conversions.patch
checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch
treewide-remove-stringification-from-__alias-macro-definition.patch


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

* Re: + checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch added to -mm tree
  2020-12-10  0:02 + checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch added to -mm tree akpm
@ 2020-12-11 17:53 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2020-12-11 17:53 UTC (permalink / raw)
  To: akpm, mm-commits

On Wed, 2020-12-09 at 16:02 -0800, akpm@linux-foundation.org wrote:
> The patch titled
>      Subject: checkpatch: add printk_once and printk_ratelimit to prefer pr_<level> warning
> has been added to the -mm tree.  Its filename is
>      checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch

I stuffed this one up.

It also needs:

 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 52f467fd32f9..00085308ed9d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4548,6 +4548,7 @@ sub process {
 			my $printk = $1;
 			my $modifier = $2;
 			my $orig = $3;
+			$modifier = "" if (!defined($modifier));
 			my $level = lc($orig);
 			$level = "warn" if ($level eq "warning");
 			my $level2 = $level;



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

end of thread, other threads:[~2020-12-11 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10  0:02 + checkpatch-add-printk_once-and-printk_ratelimit-to-prefer-pr_level-warning.patch added to -mm tree akpm
2020-12-11 17:53 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).