The project aims to extend GCC’s static analyzer to support reporting warnings for “misuse” of POSIX FD APIs such as double-close, leakage, access mode mismatch etc. by implementing the state machine that checks such misuse. Also, the project aims to add three attributes for use on functions that work with file descriptors
The static analyzer can now recognize functions open, close, read, write, creat, dup, dup2 and dup3 and report their misuse accordingly.
The project added five new warnings to GCC relating to misuse of file descriptors
- -Wanalyzer-fd-access-mode-mismatch (https://godbolt.org/z/4j6zeqG1h)
- -Wanalyzer-fd-double-close (https://godbolt.org/z/eYEf8Eorb)
- -Wanalyzer-fd-leak (https://godbolt.org/z/q7e6GKoM9)
- -Wanalyzer-fd-use-after-close (https://godbolt.org/z/dK6oWKoM5)
- -Wanalyzer-fd-use-without-check (https://godbolt.org/z/n5aMo5b1K)
For more information on above mentioned warnings, refer to the documentation here.
The project also added three new function attribute to the GCC for use on functions that deal with file descriptors:
- __attribute__((fd_arg(N))) (https://godbolt.org/z/hjxPhPaf9)
- __attribute__((fd_arg_read(N))) (https://godbolt.org/z/PjYsjd93T)
- __attribute__((fd_arg_write(N))) (https://godbolt.org/z/PYGE7b4ra)
Documentaion for usage of the new attributes is here
97baacba
analyzer: implement five new warnings for misuse of POSIX file descriptor APIs [PR106003].f8e6e2c04
Adding three new function attributes for static analysis of file descriptors.6a11f2d9
analyzer: support for creat, dup, dup2 and dup3 [PR106298].
Here is a list of all my commits.