1.. title:: clang-tidy - linuxkernel-must-use-errs 2 3linuxkernel-must-use-errs 4========================= 5 6Checks Linux kernel code to see if it uses the results from the functions in 7``linux/err.h``. Also checks to see if code uses the results from functions that 8directly return a value from one of these error functions. 9 10This is important in the Linux kernel because ``ERR_PTR``, ``PTR_ERR``, 11``IS_ERR``, ``IS_ERR_OR_NULL``, ``ERR_CAST``, and ``PTR_ERR_OR_ZERO`` return 12values must be checked, since positive pointers and negative error codes are 13being used in the same context. These functions are marked with 14``__attribute__((warn_unused_result))``, but some kernel versions do not have 15this warning enabled for clang. 16 17Examples: 18 19.. code-block:: c 20 21 /* Trivial unused call to an ERR function */ 22 PTR_ERR_OR_ZERO(some_function_call()); 23 24 /* A function that returns ERR_PTR. */ 25 void *fn() { ERR_PTR(-EINVAL); } 26 27 /* An invalid use of fn. */ 28 fn(); 29