mirror of
https://github.com/torvalds/linux.git
synced 2026-11-15 23:10:29 +01:00
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
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Alexei Lazar <alazar@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/1758192227-701925-2-git-send-email-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||
|---|---|---|
| .. | ||
| add_namespace.cocci | ||
| array_size_dup.cocci | ||
| array_size.cocci | ||
| badty.cocci | ||
| boolconv.cocci | ||
| cond_no_effect.cocci | ||
| cstptr.cocci | ||
| do_div.cocci | ||
| doubleinit.cocci | ||
| excluded_middle.cocci | ||
| flexible_array.cocci | ||
| ifcol.cocci | ||
| irqf_oneshot.cocci | ||
| minmax.cocci | ||
| newline_in_nl_msg.cocci | ||
| noderef.cocci | ||
| of_table.cocci | ||
| orplus.cocci | ||
| ptr_err_to_pe.cocci | ||
| returnvar.cocci | ||
| secs_to_jiffies.cocci | ||
| semicolon.cocci | ||
| struct_size.cocci | ||
| swap.cocci | ||
| test_addr.cocci | ||
| uninitialized_var.cocci | ||
| warn.cocci | ||