jcai19 marked an inline comment as done.
jcai19 added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/android/PosixReturnCheck.cpp:39
+ const auto &BinOp = *Result.Nodes.getNodeAs<BinaryOperator>("binop");
+ diag(BinOp.getOperatorLoc(), "posix functions (except posix_openpt) never
return negative values");
+}
----------------
jcai19 wrote:
> george.burgess.iv wrote:
> > would it be helpful to add fixits for simple cases? e.g. we can probably
> > offer to replace `posix_whatever() < 0` with `posix_whatever() > 0` or `!=
> > 0`
> While this fix is handy, I am not sure whether it will be safe enough under
> all circumstances. For example, is it possible in the code block following
> the check, the program calls another POSIX function and alter the errno
> before its value it checked? In that case, maybe the proper fix should be
> something as follows and fixing it by changing the binary operator may
> obscure it:
>
> int ret = posix_whatever();
> if (ret != 0)
After some offline discussion, I agree fixing the simple cases should be fine
as programers should verify if the fixes proposed by clang-tidy are correct.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63623/new/
https://reviews.llvm.org/D63623
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits