Re: [PATCH] net: use %ld format specifier for PTR_ERR in pr_warn
From: Nathan Chancellor
Date: Sat Apr 12 2025 - 22:07:35 EST
On Sat, Apr 12, 2025 at 04:28:38PM -0700, Kuniyuki Iwashima wrote:
> From: Qasim Ijaz <qasdev00@xxxxxxxxx>
> Date: Sat, 12 Apr 2025 23:55:28 +0100
> > PTR_ERR yields type long, so use %ld format specifier in pr_warn.
>
> errno fits in the range of int, so no need to use %ld.
Sure but the compiler does not know that and will warn about the
format specifier and type mismatch:
https://lore.kernel.org/202504130642.HaAQv94V-lkp@xxxxxxxxx/
I think my comment about switching to '%pe' on basically the same patch
in lib/ref_tracker.c is relevant here too:
https://lore.kernel.org/20250413013245.GA2989337@ax162/
Cheers,
Nathan