linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Helge Deller <deller@gmx.de>, Andy Whitcroft <apw@canonical.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: add new warning when lookup_symbol_name() is used
Date: Thu, 17 Dec 2020 09:27:27 -0800	[thread overview]
Message-ID: <816c1571b4132f991089b40a759cf68afcf4af43.camel@perches.com> (raw)
In-Reply-To: <20201217171111.GA8295@ls3530.fritz.box>

On Thu, 2020-12-17 at 18:11 +0100, Helge Deller wrote:
> In most cases people use lookup_symbol_name() to resolve a kernel symbol
> and then print it via printk().
> 
> In such cases using the %ps, %pS, %pSR or %pB printk formats are easier
> to use and thus should be preferred.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -4317,6 +4317,12 @@ sub process {
>  			     "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
>  		}
> 
> +# avoid lookup_symbol_name()
> +		if ($line =~ /\blookup_symbol_name\b/) {
> +			WARN("PREFER_PRINTK_FORMAT",
> +			     "If possible prefer %ps or %pS printk format string to print symbol name instead of using lookup_symbol_name()\n" . $herecurr);
> +		}
> +
>  # check for uses of printk_ratelimit
>  		if ($line =~ /\bprintk_ratelimit\s*\(/) {
>  			WARN("PRINTK_RATELIMITED",

Huh?  nak.

lookup_symbol_name is used in the kernel a grand total of 3 times.
2 uses are kprobe, the other is fs/proc

None of the existing uses is equivalent to %ps

Why should this be applied?



  reply	other threads:[~2020-12-17 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 17:11 [PATCH] checkpatch: add new warning when lookup_symbol_name() is used Helge Deller
2020-12-17 17:27 ` Joe Perches [this message]
2020-12-17 17:42   ` Helge Deller
2020-12-17 18:15     ` Joe Perches
2020-12-17 19:15       ` Helge Deller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=816c1571b4132f991089b40a759cf68afcf4af43.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).