-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang static analysis #1721
Comments
Very short instruction: ./autogen.sh && ./configure --with-linux=<correct path> <rest of args> && scan-build --html-title="spl at $(git log -n1|grep commit)" -analyze-headers -maxloop 15 make I'm not familiar with make (and git, probably there is a much better way to determine on which commit are sources) so I know the proposition below is very erroneous but it gives idea what is needed in Makefile: clang:
scan-build --html-title="spl at $(git log -n1|grep commit)" -analyze-headers -maxloop 15 make |
Unfortunately, static analysis tends to generate false positives when applied to kernel code. A specific false positive is that Clang's static analyzer is written under the assumption that memory allocation functions can return NULL while kmem_alloc() with KM_SLEEP guarantees that they either return a value or never return at all. I suppose we could add code to catch NULL return values to silence it, but that should be unnecessary. |
Static analyzers such as coverity support annotations to avoid false positives. Does anyone know is clang provides a similar mechanism. |
@marcin-github the ./configure step should probably be run through scan-build as well @behlendorf http://clang-analyzer.llvm.org/annotations.html i guess this is what you are looking for |
Related to #1392. For anyone interested in working on this the first step would be getting the existing code base to pass the static analyzer without errors. |
We've adopted Coverity as our static checker. That said I'd love to be running multiple checkers, for example it would be nice to run this against every PR which we can't do with Coverity. However, until someone has time to work on this I'm closing the issue. |
The code base (zfs + spl) should come up clean under static analysis by clang (and others?). To assist getting and keeping clean, the build tools should be updated to include this analysis, e.g. "make clang".
See Also:
http://thread.gmane.org/gmane.linux.file-systems.zfs.user/1503
The text was updated successfully, but these errors were encountered: