<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/124474>124474</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy problem on read non-blocking file descriptor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dpetrosy
      </td>
    </tr>
</table>

<pre>
    Hi!
I found some suspicious behavior of clang-tidy(version 19.1.3). When I call read on the non-blocking file descriptor, it reports [clang-analyzer-unix.BlockInCriticalSection]

Here is some example code:

```
std::mutex mtx;

void foo()
{
 std::lock_guard<std::mutex> lock(mtx);

    const char *filename = "example.txt";
    int fd = open(filename, O_RDONLY | O_NONBLOCK);

 char buffer[200] = {};
    read(fd, buffer, 199);
    close(fd);
}

int main()
{
    std::thread th(foo);
    th.join();
    return 0;
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8U01v4zYQ_TWjy8CCNJQi66CDP2ps0EUCtIeipwUlji1uKVIgKcPpry9oO3HSwwIGDJHzPvRGT4agT5a5g3oL9T6TSxyd79TM0bvwlvVOvXXfNFAJxeYZj26xCoObGMMSZj1otwTseZRn7Ty6Iw5G2tMqavUGtD6zD9pZLNu8zAVQm-NfI1t8xkEag56lQmcxjozW2VVv3PCPtic8asOoOAxez9F5oB3qiJ5n52NAqLc3FWmlefuX_Wqx-pJvE_rZ7ryOepDmTx6idhbqPRQbKDbf2DPqcDPPFznNhnFwikFsbhPwVNx_xSZElc7FZloiX3CKFxDb29jZaYVH54DWQG06a9INfkCSjx-nRXoFYveVCMRvmK6B1omS2g9WRMTB2RBxGKVHoE0KwcqJEcQegejuOY-XCEQ3YEJpG_GorlNuZgu0fkem3F5__LF_ffn-N0KTHl5eX7bfX3e_f5G-KvbL8cge6i0VBdT7m2qzhWb_kEoLS_wqMd8BtMOybT_4ru9hXOD73LtMc19DcjtJbf-fHuIjwDhev4w4Jo4U9CfuOOY_3Qf8k7O4eIvFF7X3fWaqE6oVrcy4KxvRtGVVtW02dmshleqfVNk0Vb0W3JfFUD61VFBTCy6rTHdUUF2U9FSui1K0eVHKXgq5JlELOnIFVcGT1CY35jzlzp8yHcLCXUlV1VSZkT2bcC0X0edqUCqb7xJq1S-nAFVhdIjhwRN1NNw9MDh71xueUmGu8fyqMdniTTfGOIeUKB2ADicdx6XPBzcBHZLK_W81e_eThwh0uFoPQIe7-3NH_wUAAP__l5U-RA">