1// SPDX-License-Identifier: GPL-2.0-only 2/// Use %pe format specifier instead of PTR_ERR() for printing error pointers. 3/// 4/// For printing error pointers (i.e., a pointer for which IS_ERR() is true) 5/// %pe will print a symbolic error name (e.g., -EINVAL), opposed to the raw 6/// errno (e.g., -22) produced by PTR_ERR(). 7/// It also makes the code cleaner by saving a redundant call to PTR_ERR(). 8/// 9// Confidence: High 10// Copyright: (C) 2025 NVIDIA CORPORATION & AFFILIATES. 11// URL: https://coccinelle.gitlabpages.inria.fr/website 12// Options: --no-includes --include-headers 13 14virtual context 15virtual org 16virtual report 17 18@r@ 19expression ptr; 20constant fmt; 21position p; 22identifier print_func; 23@@ 24* print_func(..., fmt, ..., PTR_ERR@p(ptr), ...) 25 26@script:python depends on r && report@ 27p << r.p; 28@@ 29coccilib.report.print_report(p[0], "WARNING: Consider using %pe to print PTR_ERR()") 30 31@script:python depends on r && org@ 32p << r.p; 33@@ 34coccilib.org.print_todo(p[0], "WARNING: Consider using %pe to print PTR_ERR()") 35