================
@@ -315,16 +342,54 @@ bool 
BlockInCriticalSectionChecker::isBlockingInCritSection(
 void BlockInCriticalSectionChecker::checkPostCall(const CallEvent &Call,
                                                   CheckerContext &C) const {
   if (isBlockingInCritSection(Call, C)) {
+    // for 'read' and 'recv' call, check whether it's file descriptor(first
+    // argument) is
+    // created by 'open' API with O_NONBLOCK flag or is equal to -1, they will
+    // not cause block in these situations, don't report
+    StringRef FuncName = Call.getCalleeIdentifier()->getName();
+    if (FuncName == "read" || FuncName == "recv") {
----------------
flovent wrote:

would't this make the detected functions less obvious? there is a `open`, 
`read`, `recv` and another blocking calls, it may not be very clear which are 
in blocking functioins, like this
```
  const CallDescriptionSet AnotherBlockingFunctions{{CDM::CLibrary, {"sleep"}},
                                                    {CDM::CLibrary, {"getc"}},
                                                    {CDM::CLibrary, {"fgets"}}};

  const CallDescription ReadFunction{CDM::CLibrary, {"read"}, 3};

  const CallDescription RecvFunction{CDM::CLibrary, {"recv"}, 4};

  const CallDescription OpenFunction{CDM::CLibrary, {"open"}, 2};
```

https://github.com/llvm/llvm-project/pull/127049
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to