xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/bugprone/posix-return.rst (revision 6e566bc5523f743bc34a7e26f050f1f2b4d699a8)
1.. title:: clang-tidy - bugprone-posix-return
2
3bugprone-posix-return
4=====================
5
6Checks if any calls to ``pthread_*`` or ``posix_*`` functions
7(except ``posix_openpt``) expect negative return values. These functions return
8either ``0`` on success or an ``errno`` on failure, which is positive only.
9
10Example buggy usage looks like:
11
12.. code-block:: c
13
14  if (posix_fadvise(...) < 0) {
15
16This will never happen as the return value is always non-negative. A simple fix could be:
17
18.. code-block:: c
19
20  if (posix_fadvise(...) > 0) {
21