Re: [PATCH net-next 1/2] scripts/coccinelle: Find PTR_ERR() to %pe candidates
From: Jakub Kicinski
Date: Mon Sep 22 2025 - 19:36:42 EST
On Thu, 18 Sep 2025 13:43:46 +0300 Tariq Toukan wrote:
> Add a new Coccinelle script to identify places where PTR_ERR() is used
> in print functions and suggest using the %pe format specifier instead.
>
> For printing error pointers (i.e., a pointer for which IS_ERR() is true)
> %pe will print a symbolic error name (e.g,. -EINVAL), opposed to the raw
> errno (e.g,. -22) produced by PTR_ERR().
> It also makes the code cleaner by saving a redundant call to PTR_ERR().
>
> The script supports context, report, and org modes.
>
> Example transformation:
> printk("Error: %ld\n", PTR_ERR(ptr)); // Before
> printk("Error: %pe\n", ptr); // After
Hi Julia, Nicolas,
would you be willing to give us a review tag for this script?
Would you prefer to take the script via your tree?
https://lore.kernel.org/all/1758192227-701925-2-git-send-email-tariqt@xxxxxxxxxx/