llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Qasim Ijaz <qasdev00@gmail.com>
Cc: jlayton@kernel.org, akpm@linux-foundation.org,
	llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] ref_tracker: use %ld format specifier for PTR_ERR() during directory creation failure
Date: Sat, 12 Apr 2025 20:32:45 -0500	[thread overview]
Message-ID: <20250413013245.GA2989337@ax162> (raw)
In-Reply-To: <20250412222744.9459-1-qasdev00@gmail.com>

Hi Qasim,

On Sat, Apr 12, 2025 at 11:27:44PM +0100, Qasim Ijaz wrote:
> PTR_ERR yields type long, so use %ld format specifier in pr_warn.
> 
> Fixes: ada5a12aae58 ("ref_tracker: add a top level debugfs directory for ref_tracker")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202504130520.rX5EVbVq-lkp@intel.com/ 
> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> 
> ---
>  lib/ref_tracker.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
> index 4064154252a6..02e9f0c3dd82 100644
> --- a/lib/ref_tracker.c
> +++ b/lib/ref_tracker.c
> @@ -283,7 +283,7 @@ static int __init ref_tracker_debug_init(void)
>  {
>  	ref_tracker_debug_dir = debugfs_create_dir("ref_tracker", NULL);
>  	if (IS_ERR(ref_tracker_debug_dir)) {
> -		pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %d\n",
> +		pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %ld\n",

While there is nothing wrong with doing this to resolve the warning, I
think this would be a good opportunity to use the '%pe' format specifier
[1] instead of '%ld', as that will print the symbolic error name (such
as -EINVAL instead of just -22) and make it easier for people to
decipher what has gone wrong.

  pr_warn("ref_tracker: unable to create ref_tracker debugfs directory: %pe\n",
          ref_tracker_debug_dir);

[1]: From the "error pointers" section in Documentation/core-api/printk-formats.rst

Cheers,
Nathan

>  			PTR_ERR(ref_tracker_debug_dir));
>  		ref_tracker_debug_dir = NULL;
>  	}
> -- 
> 2.39.5
> 
> 

  reply	other threads:[~2025-04-13  1:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-12 22:27 [PATCH] ref_tracker: use %ld format specifier for PTR_ERR() during directory creation failure Qasim Ijaz
2025-04-13  1:32 ` Nathan Chancellor [this message]
2025-04-13 10:50   ` Qasim Ijaz
2025-04-14  0:21     ` Nathan Chancellor

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=20250413013245.GA2989337@ax162 \
    --to=nathan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=jlayton@kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=qasdev00@gmail.com \
    /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).