Static analyzer false positive of Unix API violation: Improper use of 'open', when 'open' is in an alternative namespace
| Bugzilla Link | 28331 |
| Resolution | FIXED |
| Resolved on | Dec 20, 2016 00:00 |
| Version | 3.9 |
| OS | All |
| Attachments | sample code demonstrating Unix API violation false positive |
| Reporter | LLVM Bugzilla Contributor |
| CC | @devincoughlin,@jefftrull,@xiangzhai |
Extended Description
When the function open() appears in an alternative namespace with an unusual number of arguments, the static analyzer still reports it as a violation of the standard Unix function open().
This behavior occurs in checker-278: clang version 3.8.0 (tags/checker/checker-278) Target: x86_64-apple-darwin15.2.0
Apple Clang: Apple LLVM version 7.0.2 (clang-700.1.81) Target: x86_64-apple-darwin15.2.0
and Ubuntu 16.04 Clang: clang version 3.8.0-2ubuntu3 (tags/RELEASE_380/final) Target: x86_64-pc-linux-gnu
The attached code demonstrates this behavior with:
❯ clang++ --analyze main.cc
main.cc:17:3: warning: Call to 'open' with more than three arguments
outer::inner::open(ofs_, "foo");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
Leslie, r290023 changed checkPreStmt to not call any of the check
() methods when the function is defined inside a namespace.
Thanks for your patch! http://koji.isoft-linux.org/koji/buildinfo?buildID=4794 testcase: k3b v17.04.0 works for me ;-)
Regards, Leslie Zhai
Thanks for the fix! Won't be able to test until after the New Year. I'll re-open if necessary.
Leslie, r290023 changed checkPreStmt to not call any of the check
You can see just the changes in that commit at:
https://github.com/llvm-mirror/clang/commit/ac7583ae2b142a8e95a2150ef5f702eea6fee827
Or, using svn from the command line:
svn diff -c 290023
This should be fixed in r290023.
Hi Devin,
svn diff -r 290023 > 290023.patch about 4512 lines patch, but I did NOT find how to prevent UnixAPIChecker::CheckOpen from UnixAPIChecker::checkPreStmt, please give me some advice, thanks a lot!
Regards, Leslie Zhai
This should be fixed in r290023.
The same story for KStandardAction::open, it is KDE some library's namespace!
assigned to @tkremenek