[PATCH] D63623: [clang-tidy] Add a check on expected return values of posix functions (except posix_openpt) in Android module.

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 06:49:23 PDT 2019


gribozavr accepted this revision.
gribozavr added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst:21
+  int ret = posix_fadvise(...);
+  if (ret != 0) ...
----------------
why not `if (posix_fadvise() != 0)` ?

Otherwise it looks like adding a variable is necessary for a fix.


================
Comment at: clang-tools-extra/test/clang-tidy/android-posix-return.cpp:8
+typedef long off_t;
+typedef int size_t;
+typedef int pid_t;
----------------
`typedef decltype(sizeof(char)) size_t;`


================
Comment at: clang-tools-extra/test/clang-tidy/android-posix-return.cpp:67
+  if (posix_openpt(0) == -1) {}
+  if (posix_fadvise(0, 0, 0, 0) >= 0) {}
+  if (posix_fadvise(0, 0, 0, 0) == 1) {}
----------------
What about

```
if (posix_fadvise() >= 0) { ... } else { ... }
```

?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63623/new/

https://reviews.llvm.org/D63623





More information about the cfe-commits mailing list